1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN"> |
---|
2 | |
---|
3 | <html> |
---|
4 | <head> |
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
---|
6 | <title>Boost.MultiIndex Documentation - Compiler specifics</title> |
---|
7 | <link rel="stylesheet" href="style.css" type="text/css"> |
---|
8 | </head> |
---|
9 | |
---|
10 | <body> |
---|
11 | <h1><img src="../../../boost.png" alt="boost.png (6897 bytes)" align= |
---|
12 | "middle" width="277" height="86">Boost.MultiIndex Compiler specifics</h1> |
---|
13 | |
---|
14 | <div class="prev_link"><a href="reference/key_extraction.html"><img src="prev.gif" alt="key extraction" border="0"><br> |
---|
15 | Key extraction |
---|
16 | </a></div> |
---|
17 | <div class="up_link"><a href="index.html"><img src="up.gif" alt="index" border="0"><br> |
---|
18 | Index |
---|
19 | </a></div> |
---|
20 | <div class="next_link"><a href="performance.html"><img src="next.gif" alt="performance" border="0"><br> |
---|
21 | Performance |
---|
22 | </a></div><br clear="all" style="clear: all;"> |
---|
23 | |
---|
24 | <hr> |
---|
25 | |
---|
26 | <p> |
---|
27 | Boost.MultiIndex has been tried in different compilers, with |
---|
28 | various degrees of success. We list the limitations encountered, |
---|
29 | along with suitable workarounds when available. |
---|
30 | </p> |
---|
31 | |
---|
32 | <h2>Contents</h2> |
---|
33 | |
---|
34 | <ul> |
---|
35 | <li><a href="#bcb_64">Borland C++ Builder 6.4</a></li> |
---|
36 | <li><a href="#comeau_433_win_vc7_71">Comeau C/C++ 4.3.3 for Windows (VC++ 7.0/7.1 backend)</a></li> |
---|
37 | <li><a href="#compaq_65">Compaq C++ 6.5-042 for Tru64 UNIX and later</a></li> |
---|
38 | <li> |
---|
39 | <a href="#gcc_32">GNU GCC 3.2 and later</a> |
---|
40 | <ul> |
---|
41 | <li><a href="#gcc_tru64">GNU GCC for Tru64 UNIX</a></li> |
---|
42 | <li><a href="#gcc_4_darwin">Darwin GCC 4.0</a></li> |
---|
43 | </ul> |
---|
44 | </li> |
---|
45 | <li><a href="#acc_60">HP aC++ A.06.00 for HP-UX</a></li> |
---|
46 | <li><a href="#va_60">IBM VisualAge C++ V6.0 for AIX</a></li> |
---|
47 | <li><a href="#intel_71_lin">Intel C++ Compiler for Linux 7.1 and later</a></li> |
---|
48 | <li><a href="#intel_em64t_81_lin">Intel C++ Compiler Extended Memory 64 Technology 8.1 for Linux</a></li> |
---|
49 | <li><a href="#intel_7x_win">Intel C++ Compiler for Windows 32-bit 7.0/7.1</a></li> |
---|
50 | <li><a href="#intel_71_win_stlport_453">Intel C++ Compiler for Windows 32-bit 7.1 + STLport 4.5.3</a></li> |
---|
51 | <li><a href="#intel_80_win">Intel C++ Compiler for Windows 32-bit 8.0 and later</a></li> |
---|
52 | <li><a href="#cw_83">Metrowerks CodeWarrior 8.3 and later</a></li> |
---|
53 | <li><a href="#msvc_60">Microsoft Visual C++ 6.0 Service Pack 5</a></li> |
---|
54 | <li><a href="#msvc_60_stlport_453">Microsoft Visual C++ 6.0 Service Pack 5 + STLport 4.5.3</a></li> |
---|
55 | <li><a href="#msvc_70">Microsoft Visual C++ 7.0</a></li> |
---|
56 | <li><a href="#msvc_71">Microsoft Visual C++ 7.1</a></li> |
---|
57 | <li><a href="#msvc_71_stlport_462">Microsoft Visual C++ 7.1 + STLport 4.6.2</a></li> |
---|
58 | <li><a href="#msvc_80">Microsoft Visual C++ 8.0</a></li> |
---|
59 | <li><a href="#portability">Portability techniques</a> |
---|
60 | <ul> |
---|
61 | <li><a href="#member_offset">Use of <code>member_offset</code></a></li> |
---|
62 | <li><a href="#mem_fun_explicit">Use of <code>const_mem_fun_explicit</code> and |
---|
63 | <code>mem_fun_explicit</code></a></li> |
---|
64 | <li><a href="#composite_key_no_pts"><code>composite_key</code> in compilers |
---|
65 | without partial template specialization</a></li> |
---|
66 | <li><a href="#symbol_reduction">Reduction of symbol name lengths</a> |
---|
67 | <ul> |
---|
68 | <li><a href="#argument_limitation">Limitation of maximum number of arguments</a></li> |
---|
69 | <li><a href="#type_hiding">Type hiding</a></li> |
---|
70 | </ul> |
---|
71 | </li> |
---|
72 | </ul> |
---|
73 | </li> |
---|
74 | </ul> |
---|
75 | |
---|
76 | <h2><a name="bcb_64">Borland C++ Builder 6.4</a></h2> |
---|
77 | |
---|
78 | <p> |
---|
79 | Currently, Boost.MultiIndex cannot be used with BCB 6.4. The |
---|
80 | number of problems encountered during the tests makes it unlikely that |
---|
81 | future versions of the library can be made to work under |
---|
82 | this compiler. |
---|
83 | </p> |
---|
84 | |
---|
85 | <h2><a name="comeau_433_win_vc7_71">Comeau C/C++ 4.3.3 for Windows (VC++ 7.0/7.1 backend)</a></h2> |
---|
86 | |
---|
87 | <p> |
---|
88 | No problems have been detected with this compiler. The library fails to compile, |
---|
89 | however, when Microsoft Visual C++ 6.0 is used as the backend. |
---|
90 | </p> |
---|
91 | |
---|
92 | <h2><a name="compaq_65">Compaq C++ 6.5-042 for Tru64 UNIX and later</a></h2> |
---|
93 | |
---|
94 | <p> |
---|
95 | No problems have been detected with this compiler. Versions 6.5-042, |
---|
96 | 7.1-005 and 7.1-006 have been tested. |
---|
97 | </p> |
---|
98 | |
---|
99 | <h2><a name="gcc_32">GNU GCC 3.2 and later</a></h2> |
---|
100 | |
---|
101 | <p> |
---|
102 | No problems have been detected with several versions of this compiler |
---|
103 | starting from 3.2. The following versions have been explicitly tested: |
---|
104 | <ul> |
---|
105 | <li>GCC 3.2 20020903 under Linux,</li> |
---|
106 | <li>GCC 3.2 20020927 (prerelease) under Cygwin 1.5.7,</li> |
---|
107 | <li>GCC 3.2.3 under Linux, (mingw special 20030504-1) under Win32,</li> |
---|
108 | <li>GCC 3.3 20030304 (Apple builds 1666 and 1671) under Mac OS,</li> |
---|
109 | <li>GCC 3.3.3 (cygwin special) under Cygwin 1.5.7,</li> |
---|
110 | <li>GCC 3.3.5 under Linux,</li> |
---|
111 | <li>GCC 3.3.6 under Linux and Tru64 (see <a href="#gcc_tru64">below</a>),</li> |
---|
112 | <li>GCC 3.4.2 (mingw-special) under Win32,</li> |
---|
113 | <li>GCC 3.4.3 under Linux, Solaris and Tru64 (see <a href="#gcc_tru64">below</a>),</li> |
---|
114 | <li>GCC 3.4.4 (cygming special) under Cygwin, under Gentoo Linux PPC64, under Linux, |
---|
115 | under Tru64 (see <a href="#gcc_tru64">below</a>), (mingw special) under Win32,</li> |
---|
116 | <li>GCC 4.0.0 20041026 (Apple build 4061) under Mac OS |
---|
117 | (see <a href="#gcc_4_darwin">below</a>),</li> |
---|
118 | <li>GCC 4.0.0 under Linux, (Apple build 5026) under Mac OS,</li> |
---|
119 | <li>GCC 4.0.1 under Linux and Tru64 (see <a href="#gcc_tru64">below</a>),</li> |
---|
120 | <li>GCC 4.0.2 under Linux.</li> |
---|
121 | </ul> |
---|
122 | Boost.MultiIndex does not work with versions 3.1 and prior of GCC. |
---|
123 | </p> |
---|
124 | |
---|
125 | <h3><a name="gcc_tru64">GNU GCC for Tru64 UNIX</a></h3> |
---|
126 | |
---|
127 | <p> |
---|
128 | On this platform, GCC is not able to handle debug symbol names whose length |
---|
129 | exceeds 32,768 bytes, resulting in the error <code>mips-tfile, ... string |
---|
130 | too big</code>. You may encounter this issue with heavily templatized |
---|
131 | code like Boost.MultiIndex, which typically produces long symbol names. The problem |
---|
132 | can be overcome by omitting the compiler option <code>-g</code> (generate debugging |
---|
133 | information.) Alternatively, consult the section on |
---|
134 | <a href="#symbol_reduction">reduction of symbol name lengths</a> for various |
---|
135 | applicable workarounds. |
---|
136 | </p> |
---|
137 | |
---|
138 | <h3><a name="gcc_4_darwin">Darwin GCC 4.0</a></h3> |
---|
139 | |
---|
140 | <p> |
---|
141 | Build 4061 of GCC 4.0, shipped with Darwin 8.2 and prior (Mac OS X 10.4.2 and |
---|
142 | prior), corresponds to a prerelease version of GNU GCC 4.0.0 which introduces |
---|
143 | a <a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17435">regression bug</a> |
---|
144 | related to binding of references to temporary objects. This bug precludes the |
---|
145 | usage of Boost.MultiIndex |
---|
146 | <a href="advanced_topics.html#invariant_check">invariant-checking mode</a>; other |
---|
147 | than this, Boost.MultiIndex works correctly. |
---|
148 | The bug is corrected in GCC 4.0 Apple build 5026, which is in sync with the official |
---|
149 | release of GNU GCC 4.0.0, so the invariant-checking mode is available from this |
---|
150 | upgrade. |
---|
151 | </p> |
---|
152 | |
---|
153 | <h2><a name="acc_60">HP aC++ A.06.00 for HP-UX</a></h2> |
---|
154 | |
---|
155 | <p> |
---|
156 | No problems have been detected with this compiler. |
---|
157 | </p> |
---|
158 | |
---|
159 | <h2><a name="va_60">IBM VisualAge C++ V6.0 for AIX</a></h2> |
---|
160 | |
---|
161 | <p> |
---|
162 | <a href="reference/key_extraction.html#member"><code>member</code></a> not supported, |
---|
163 | refer to the section on |
---|
164 | <a href="#member_offset">use of <code>member_offset</code></a> for workarounds. |
---|
165 | <code>member_offset</code> causes the compiler to emit warnings about the |
---|
166 | use of <code>offsetof</code> with non-POD types: these warnings can be suppressed |
---|
167 | by setting the compiler option <code>-qsuppress=1540-1281</code>, or, alternatively, |
---|
168 | by inserting the following preprocessor directive: |
---|
169 | </p> |
---|
170 | |
---|
171 | <blockquote><pre> |
---|
172 | <span class=preprocessor>#pragma</span> <span class=identifier>info</span><span class=special>(</span><span class=identifier>nolan</span><span class=special>)</span> |
---|
173 | </pre></blockquote> |
---|
174 | |
---|
175 | <p> |
---|
176 | This latter pragma, however, may also eliminate other warnings not related |
---|
177 | to the use of <code>offsetof</code>. |
---|
178 | </p> |
---|
179 | |
---|
180 | <blockquote><hr></blockquote> |
---|
181 | |
---|
182 | <p> |
---|
183 | Serialization capabilities are not available as Boost.Serialization is not |
---|
184 | supported on this platform. |
---|
185 | </p> |
---|
186 | |
---|
187 | <h2><a name="intel_71_lin">Intel C++ Compiler for Linux 7.1 and later</a></h2> |
---|
188 | |
---|
189 | <p> |
---|
190 | No problems have been detected with this compilers from version 7.1 up to 9.0. |
---|
191 | </p> |
---|
192 | |
---|
193 | <h2><a name="intel_em64t_81_lin">Intel C++ Compiler Extended Memory 64 Technology 8.1 |
---|
194 | for Linux</a></h2> |
---|
195 | |
---|
196 | <p> |
---|
197 | No problems have been detected with this compiler. |
---|
198 | </p> |
---|
199 | |
---|
200 | <h2><a name="intel_7x_win">Intel C++ Compiler for Windows 32-bit 7.0/7.1</a></h2> |
---|
201 | |
---|
202 | <p> |
---|
203 | <a href="reference/key_extraction.html#member"><code>member</code></a> not supported, |
---|
204 | refer to the section on |
---|
205 | <a href="#member_offset">use of <code>member_offset</code></a> for workarounds. |
---|
206 | </p> |
---|
207 | |
---|
208 | <blockquote><hr></blockquote> |
---|
209 | |
---|
210 | <p> |
---|
211 | When used on top of MSVC++ 7.0 or prior, argument dependent lookup is |
---|
212 | disabled by default. This will cause problems with many Boost libraries, |
---|
213 | and in particular with the serialization part of Boost.MultiIndex. |
---|
214 | Argument dependent lookup is enabled by adding |
---|
215 | <code>/Qoption,c,--arg_dep_lookup</code> to the project options. |
---|
216 | </p> |
---|
217 | |
---|
218 | <h2><a name="intel_71_win_stlport_453"> |
---|
219 | Intel C++ Compiler for Windows 32-bit 7.1 + STLport 4.5.3</a></h2> |
---|
220 | |
---|
221 | <p> |
---|
222 | Boost.MultiIndex works for this configuration. The same limitations apply as |
---|
223 | in Intel C++ 7.1 with its original Dinkumware standard library. STLport 4.6.2 has |
---|
224 | also been confirmed to work correctly. |
---|
225 | </p> |
---|
226 | |
---|
227 | <h2><a name="intel_80_win">Intel C++ Compiler for Windows 32-bit 8.0 and later</a></h2> |
---|
228 | |
---|
229 | <p> |
---|
230 | When used on top of MSVC++ 7.0 or prior, argument dependent lookup is |
---|
231 | disabled by default. This will cause problems with many Boost libraries, |
---|
232 | and in particular with the serialization part of Boost.MultiIndex. |
---|
233 | Argument dependent lookup is enabled by adding |
---|
234 | <code>/Qoption,c,--arg_dep_lookup</code> to the project options. |
---|
235 | Other than this, Boost.MultiIndex works without problems. Compiler versions |
---|
236 | from 8.0 to 9.0 have been tested. |
---|
237 | </p> |
---|
238 | |
---|
239 | <h2><a name="cw_83">Metrowerks CodeWarrior 8.3 and later</a></h2> |
---|
240 | |
---|
241 | <p> |
---|
242 | Boost.MultiIndex works correctly with versions of this compiler from 8.3 to |
---|
243 | 9.5, under the two operating systems tested: Mac OS and Windows. |
---|
244 | </p> |
---|
245 | |
---|
246 | <h2><a name="msvc_60">Microsoft Visual C++ 6.0 Service Pack 5</a></h2> |
---|
247 | |
---|
248 | <p> |
---|
249 | <a href="reference/key_extraction.html#member"><code>member</code></a> not supported, |
---|
250 | refer to the section on |
---|
251 | <a href="#member_offset">use of <code>member_offset</code></a> for workarounds. |
---|
252 | </p> |
---|
253 | |
---|
254 | <p> |
---|
255 | <a href="reference/key_extraction.html#const_mem_fun"><code>const_mem_fun</code></a> and |
---|
256 | <a href="reference/key_extraction.html#mem_fun"><code>mem_fun</code></a> |
---|
257 | not supported, refer to the section on |
---|
258 | <a href="#mem_fun_explicit">use of <code>const_mem_fun_explicit</code> and |
---|
259 | <code>mem_fun_explicit</code></a> for workarounds. |
---|
260 | </p> |
---|
261 | |
---|
262 | <blockquote><hr></blockquote> |
---|
263 | |
---|
264 | <p> |
---|
265 | No support for <a href="reference/multi_index_container.html#index_retrieval">index retrieval</a> |
---|
266 | and <a href="reference/multi_index_container.html#projection">projection</a> |
---|
267 | nested types and member functions: |
---|
268 | <ul> |
---|
269 | <li><code>nth_index</code>,</li> |
---|
270 | <li><code>index</code>,</li> |
---|
271 | <li><code>nth_index_iterator</code>,</li> |
---|
272 | <li><code>nth_index_const_iterator</code>,</li> |
---|
273 | <li><code>index_iterator</code>,</li> |
---|
274 | <li><code>index_const_iterator</code>,</li> |
---|
275 | <li><code>get</code>,</li> |
---|
276 | <li><code>project</code>.</li> |
---|
277 | </ul> |
---|
278 | You can use instead their global equivalents. Also, this compiler does not |
---|
279 | implement argument dependent lookup, so you might need to explicitly qualify |
---|
280 | these global names with <code>::boost::multi_index</code>. |
---|
281 | </p> |
---|
282 | |
---|
283 | <blockquote><hr></blockquote> |
---|
284 | |
---|
285 | <p> |
---|
286 | <code>boost::multi_index::multi_index_container</code> is imported to |
---|
287 | <code>namespace boost</code> by means of a <code>using</code> declaration. |
---|
288 | MSVC++ 6.0, however, does not properly handle this import. So, instead of |
---|
289 | writing: |
---|
290 | </p> |
---|
291 | |
---|
292 | <blockquote><pre> |
---|
293 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index_container</span><span class=special><...></span> |
---|
294 | </pre></blockquote> |
---|
295 | |
---|
296 | <p> |
---|
297 | use the following: |
---|
298 | </p> |
---|
299 | |
---|
300 | <blockquote><pre> |
---|
301 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>::</span><span class=identifier>multi_index_container</span><span class=special><...></span> |
---|
302 | </pre></blockquote> |
---|
303 | |
---|
304 | <p> |
---|
305 | or else resort to a directive <code>using namespace boost::multi_index</code>. |
---|
306 | </p> |
---|
307 | |
---|
308 | <blockquote><hr></blockquote> |
---|
309 | |
---|
310 | <p> |
---|
311 | The lack of partial template specialization support in MSVC++ 6.0 |
---|
312 | results in some inconveniences when using <code>composite_key</code> that |
---|
313 | can be remedied as explained in |
---|
314 | <a href="#composite_key_no_pts">"<code>composite_key</code> |
---|
315 | in compilers without partial template specialization"</a>. |
---|
316 | </p> |
---|
317 | |
---|
318 | <blockquote><hr></blockquote> |
---|
319 | |
---|
320 | <p> |
---|
321 | MSVC++ 6.0 presents serious limitations for the maximum length of |
---|
322 | symbol names generated by the compiler, which might result in the |
---|
323 | linker error |
---|
324 | <code><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/lnk1179.asp">LNK1179</a>: |
---|
325 | invalid or corrupt file: duplicate comdat |
---|
326 | comdat</code>. To overcome this problem, consult the section on |
---|
327 | <a href="#symbol_reduction">reduction of symbol name lengths</a> for various |
---|
328 | applicable workarounds. |
---|
329 | </p> |
---|
330 | |
---|
331 | <blockquote><hr></blockquote> |
---|
332 | |
---|
333 | <p> |
---|
334 | Under some circumstances, the compiler emits the error |
---|
335 | <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/C2587.asp"> |
---|
336 | <code>C2587</code></a><code>: '_U' : illegal use of local variable as |
---|
337 | default parameter</code>, inside the MSVC internal header |
---|
338 | <code><xlocnum></code>. |
---|
339 | This problem is a recurrent bug of the compiler, and has been reported in |
---|
340 | other unrelated libraries, like the |
---|
341 | <a href="../../../libs/graph/doc/table_of_contents.html">Boost Graph Library</a>, |
---|
342 | <a href="../../../libs/multi_array/doc/index.html">Boost.MultiArray</a>, |
---|
343 | <a href="../../../libs/regex/doc/index.html">Boost.Regex</a>, |
---|
344 | <a href="http://www.cgal.org/">CGAL</a> and |
---|
345 | <a href="http://www.mysql.com/downloads/api-mysql++.html">MySQL++</a>. |
---|
346 | The error is triggered, though not in a systematic manner, by the use |
---|
347 | of <code>multi_index_container</code> iterator constructor. Two workarounds exist: |
---|
348 | the first consists of avoiding this constructor and replacing |
---|
349 | code like: |
---|
350 | </p> |
---|
351 | |
---|
352 | <blockquote><pre> |
---|
353 | <span class=identifier>multi_index_container</span><span class=special><...></span> <span class=identifier>s</span><span class=special>(</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>end</span><span class=special>());</span> |
---|
354 | </pre></blockquote> |
---|
355 | |
---|
356 | <p> |
---|
357 | with equivalent operations: |
---|
358 | </p> |
---|
359 | |
---|
360 | <blockquote><pre> |
---|
361 | <span class=identifier>multi_index_container</span><span class=special><...></span> <span class=identifier>s</span><span class=special>;</span> |
---|
362 | <span class=identifier>s</span><span class=special>.</span><span class=identifier>insert</span><span class=special>(</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>c</span><span class=special>.</span><span class=identifier>end</span><span class=special>());</span> |
---|
363 | </pre></blockquote> |
---|
364 | |
---|
365 | <p> |
---|
366 | The second workaround has not been confirmed by the author, but it is given |
---|
367 | on the Internet in connection with this error appearing in other libraries. |
---|
368 | Replace line 84 of <code><xlocnum></code> |
---|
369 | |
---|
370 | <blockquote><pre> |
---|
371 | <span class=preprocessor>#define</span> <span class=identifier>_VIRTUAL</span> <span class=keyword>virtual</span> |
---|
372 | </pre></blockquote> |
---|
373 | |
---|
374 | <p> |
---|
375 | with the following: |
---|
376 | </p> |
---|
377 | |
---|
378 | <blockquote><pre> |
---|
379 | <span class=preprocessor>#define</span> <span class=identifier>_VIRTUAL</span> |
---|
380 | </pre></blockquote> |
---|
381 | |
---|
382 | <p> |
---|
383 | <b>Warning</b>: it is not known whether this |
---|
384 | replacement can result in unexpected side effects in code implicitly |
---|
385 | using <code><xlocnum></code>. |
---|
386 | </p> |
---|
387 | |
---|
388 | <blockquote><hr></blockquote> |
---|
389 | |
---|
390 | <p> |
---|
391 | In general, the extensive use of templates by Boost.MultiIndex puts this compiler |
---|
392 | under severe stress, so that several internal limitations may be reached. |
---|
393 | The following measures can help alleviate these problems: |
---|
394 | <ul> |
---|
395 | <li>Set the compiler option <code>/Zm</code> (Specify Memory Allocation Limit) |
---|
396 | to increase the amount of memory available for compilation. Usual values for |
---|
397 | this option range from 300 to 800.</li> |
---|
398 | <li>If in debug mode, try switching from <code>/ZI</code> (Program Database for |
---|
399 | Edit and Continue) to a less demanding type of debugging information |
---|
400 | (<code>/Zi</code>, <code>/Z7</code> or <code>/Zd</code>.)</li> |
---|
401 | <li>Play with the precompiled headers options. Usually, turning this feature |
---|
402 | off yields the best results.</li> |
---|
403 | <li>If the compiler emits the error |
---|
404 | <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/c1055.asp"> |
---|
405 | <code>C1055</code></a><code>: compiler limit : out of keys</code>, try |
---|
406 | disabling the option <code>/Gm</code> (Enable Minimal Rebuild.) In these |
---|
407 | cases, it is also beneficial to split the project into smaller |
---|
408 | subprojects.</li> |
---|
409 | </ul> |
---|
410 | </p> |
---|
411 | |
---|
412 | <h2> |
---|
413 | <a name="msvc_60_stlport_453">Microsoft Visual C++ 6.0 Service Pack 5 |
---|
414 | + STLport 4.5.3</a> |
---|
415 | </h2> |
---|
416 | |
---|
417 | <p> |
---|
418 | Boost.MultiIndex works for this configuration. The same limitations apply as |
---|
419 | in MSVC++ 6.0 with its original Dinkumware standard library. STLport 4.6.2 has |
---|
420 | also been confirmed to work correctly. |
---|
421 | </p> |
---|
422 | |
---|
423 | <blockquote><hr></blockquote> |
---|
424 | |
---|
425 | <p> |
---|
426 | It is not possible to use the serialization capabilities of Boost.MultiIndex |
---|
427 | along with the dynamic version of STLport, as some linking errors result. |
---|
428 | Use instead the static version of STLport. This bug is reportedly fixed in |
---|
429 | STLport 5.0 (in beta stage as of this writing.) |
---|
430 | </p> |
---|
431 | |
---|
432 | <h2><a name="msvc_70">Microsoft Visual C++ 7.0</a></h2> |
---|
433 | |
---|
434 | <p> |
---|
435 | <a href="reference/key_extraction.html#member"><code>member</code></a> not supported, |
---|
436 | refer to the section on |
---|
437 | <a href="#member_offset">use of <code>member_offset</code></a> for workarounds. |
---|
438 | </p> |
---|
439 | |
---|
440 | <blockquote><hr></blockquote> |
---|
441 | |
---|
442 | <p> |
---|
443 | No support for <a href="reference/multi_index_container.html#index_retrieval">index retrieval</a> |
---|
444 | and <a href="reference/multi_index_container.html#projection">projection</a> |
---|
445 | nested types and member functions: |
---|
446 | <ul> |
---|
447 | <li><code>nth_index</code>,</li> |
---|
448 | <li><code>index</code>,</li> |
---|
449 | <li><code>nth_index_iterator</code>,</li> |
---|
450 | <li><code>nth_index_const_iterator</code>,</li> |
---|
451 | <li><code>index_iterator</code>,</li> |
---|
452 | <li><code>index_const_iterator</code>,</li> |
---|
453 | <li><code>get</code>,</li> |
---|
454 | <li><code>project</code>.</li> |
---|
455 | </ul> |
---|
456 | You can use instead their global equivalents. Also, this compiler does not |
---|
457 | implement argument dependent lookup, so you might need to explicitly qualify |
---|
458 | these global names with <code>::boost::multi_index</code>. |
---|
459 | </p> |
---|
460 | |
---|
461 | <blockquote><hr></blockquote> |
---|
462 | |
---|
463 | <p> |
---|
464 | <code>boost::multi_index::multi_index_container</code> is imported to |
---|
465 | <code>namespace boost</code> by means of a <code>using</code> declaration. |
---|
466 | MSVC++ 7.0, however, does not properly handle this import. So, instead of |
---|
467 | writing: |
---|
468 | </p> |
---|
469 | |
---|
470 | <blockquote><pre> |
---|
471 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index_container</span><span class=special><...></span> |
---|
472 | </pre></blockquote> |
---|
473 | |
---|
474 | <p> |
---|
475 | use the following: |
---|
476 | </p> |
---|
477 | |
---|
478 | <blockquote><pre> |
---|
479 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>::</span><span class=identifier>multi_index_container</span><span class=special><...></span> |
---|
480 | </pre></blockquote> |
---|
481 | |
---|
482 | <p> |
---|
483 | or else resort to a directive <code>using namespace boost::multi_index</code>. |
---|
484 | </p> |
---|
485 | |
---|
486 | <blockquote><hr></blockquote> |
---|
487 | |
---|
488 | <p> |
---|
489 | The lack of partial template specialization support in MSVC++ 7.0 |
---|
490 | results in some inconveniences when using <code>composite_key</code> that |
---|
491 | can be remedied as explained in |
---|
492 | <a href="#composite_key_no_pts">"<code>composite_key</code> |
---|
493 | in compilers without partial template specialization"</a>. |
---|
494 | </p> |
---|
495 | |
---|
496 | <h2><a name="msvc_71">Microsoft Visual C++ 7.1</a></h2> |
---|
497 | |
---|
498 | <p> |
---|
499 | Problems have been reported when compiling the library with the <code>/Gm</code> |
---|
500 | option (Enable Minimal Rebuild.) Seemingly, this is due to an |
---|
501 | internal defect of the compiler (see for instance |
---|
502 | <a href="http://lists.boost.org/MailArchives/boost-users/msg05988.php"> |
---|
503 | this mention of a similar issue</a> in the Boost Users mailing list.) |
---|
504 | If <code>/Gm</code> is turned off, Boost.MultiIndex compiles and runs |
---|
505 | without further problems. |
---|
506 | </p> |
---|
507 | |
---|
508 | <h2><a name="msvc_71_stlport_462">Microsoft Visual C++ 7.1 + STLport 4.6.2</a></h2> |
---|
509 | |
---|
510 | <p> |
---|
511 | Boost.MultiIndex works for this configuration. The same issues apply as in |
---|
512 | MSVC++ 7.1 with its original Dinkumware standard library. |
---|
513 | </p> |
---|
514 | |
---|
515 | <h2><a name="msvc_80">Microsoft Visual C++ 8.0</a></h2> |
---|
516 | |
---|
517 | <p> |
---|
518 | No problems have been detected with this compiler. The Beta 2 version of |
---|
519 | this product was used for the testing. |
---|
520 | </p> |
---|
521 | |
---|
522 | <h2><a name="portability">Portability techniques</a></h2> |
---|
523 | |
---|
524 | <h3><a name="member_offset">Use of <code>member_offset</code></a></h3> |
---|
525 | |
---|
526 | <p> |
---|
527 | The <code>member</code> key extractor poses some problems in compilers |
---|
528 | that do not properly support pointers to members as non-type |
---|
529 | template arguments, as indicated by the |
---|
530 | <a href="../../../libs/config/config.htm">Boost Configuration Library</a> |
---|
531 | defect macro <code>BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS</code>. |
---|
532 | The following compilers have been confirmed not |
---|
533 | to work correctly with <code>member</code>: |
---|
534 | <ul> |
---|
535 | <li>MSVC++ 6.0/7.0,</li> |
---|
536 | <li>Intel C++ 7.0/7.1 for Windows,</li> |
---|
537 | <li>VisualAge 6.0 for AIX.</li> |
---|
538 | </ul> |
---|
539 | This program can help determine if your compiler |
---|
540 | properly supports pointers to members as non-type template parameters: |
---|
541 | </p> |
---|
542 | |
---|
543 | <blockquote><pre> |
---|
544 | <span class=preprocessor>#include</span> <span class=special><</span><span class=identifier>iostream</span><span class=special>></span> |
---|
545 | |
---|
546 | <span class=keyword>struct</span> <span class=identifier>pair</span> |
---|
547 | <span class=special>{</span> |
---|
548 | <span class=keyword>int</span> <span class=identifier>x</span><span class=special>,</span><span class=identifier>y</span><span class=special>;</span> |
---|
549 | |
---|
550 | <span class=identifier>pair</span><span class=special>(</span><span class=keyword>int</span> <span class=identifier>x_</span><span class=special>,</span><span class=keyword>int</span> <span class=identifier>y_</span><span class=special>):</span><span class=identifier>x</span><span class=special>(</span><span class=identifier>x_</span><span class=special>),</span><span class=identifier>y</span><span class=special>(</span><span class=identifier>y_</span><span class=special>){}</span> |
---|
551 | <span class=special>};</span> |
---|
552 | |
---|
553 | <span class=keyword>template</span><span class=special><</span><span class=keyword>int</span> <span class=identifier>pair</span><span class=special>::*</span> <span class=identifier>PtrToPairMember</span><span class=special>></span> |
---|
554 | <span class=keyword>struct</span> <span class=identifier>foo</span> |
---|
555 | <span class=special>{</span> |
---|
556 | <span class=keyword>int</span> <span class=identifier>bar</span><span class=special>(</span><span class=identifier>pair</span><span class=special>&</span> <span class=identifier>p</span><span class=special>){</span><span class=keyword>return</span> <span class=identifier>p</span><span class=special>.*</span><span class=identifier>PtrToPairMember</span><span class=special>;}</span> |
---|
557 | <span class=special>};</span> |
---|
558 | |
---|
559 | <span class=keyword>int</span> <span class=identifier>main</span><span class=special>()</span> |
---|
560 | <span class=special>{</span> |
---|
561 | <span class=identifier>pair</span> <span class=identifier>p</span><span class=special>(</span><span class=number>0</span><span class=special>,</span><span class=number>1</span><span class=special>);</span> |
---|
562 | <span class=identifier>foo</span><span class=special><&</span><span class=identifier>pair</span><span class=special>::</span><span class=identifier>x</span><span class=special>></span> <span class=identifier>fx</span><span class=special>;</span> |
---|
563 | <span class=identifier>foo</span><span class=special><&</span><span class=identifier>pair</span><span class=special>::</span><span class=identifier>y</span><span class=special>></span> <span class=identifier>fy</span><span class=special>;</span> |
---|
564 | |
---|
565 | <span class=keyword>if</span><span class=special>(</span><span class=identifier>fx</span><span class=special>.</span><span class=identifier>bar</span><span class=special>(</span><span class=identifier>p</span><span class=special>)!=</span><span class=number>0</span><span class=special>||</span><span class=identifier>fy</span><span class=special>.</span><span class=identifier>bar</span><span class=special>(</span><span class=identifier>p</span><span class=special>)!=</span><span class=number>1</span><span class=special>)</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>cout</span><span class=special><<</span><span class=string>"KO"</span><span class=special><<</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>endl</span><span class=special>;</span> |
---|
566 | <span class=keyword>else</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>cout</span><span class=special><<</span><span class=string>"OK"</span><span class=special><<</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>endl</span><span class=special>;</span> |
---|
567 | |
---|
568 | <span class=keyword>return</span> <span class=number>0</span><span class=special>;</span> |
---|
569 | <span class=special>}</span> |
---|
570 | |
---|
571 | </pre></blockquote> |
---|
572 | |
---|
573 | <p> |
---|
574 | If you find a compiler that does not pass the test, and for which |
---|
575 | <code>BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS</code> is <i>not</i> defined, |
---|
576 | please report to the Boost developers mailing list. |
---|
577 | </p> |
---|
578 | <p>To overcome this defect, a replacement utility |
---|
579 | <a href="reference/key_extraction.html#member_offset"><code>member_offset</code></a> |
---|
580 | has been provided that does the work of <code>member</code> at the |
---|
581 | expense of less convenient notation and the possibility of |
---|
582 | non-conformance with the standard. Please consult |
---|
583 | the reference for further information on <code>member_offset</code>. |
---|
584 | As an example of use, given the class |
---|
585 | </p> |
---|
586 | |
---|
587 | <blockquote><pre> |
---|
588 | <span class=keyword>class</span> <span class=identifier>A</span> |
---|
589 | <span class=special>{</span> |
---|
590 | <span class=keyword>int</span> <span class=identifier>x</span><span class=special>;</span> |
---|
591 | <span class=special>}</span> |
---|
592 | </pre></blockquote> |
---|
593 | |
---|
594 | <p> |
---|
595 | the instantiation <code>member<A,int,&A::x></code> can be simulated then |
---|
596 | as <code>member_offset<A,int,offsetof(A,x)></code>. |
---|
597 | </p> |
---|
598 | |
---|
599 | <p> |
---|
600 | For those writing portable code, Boost.MultiIndex provides the ternary macro |
---|
601 | <a href="reference/key_extraction.html#boost_multi_index_member"><code>BOOST_MULTI_INDEX_MEMBER</code></a>. |
---|
602 | Continuing with the example above, the |
---|
603 | expression |
---|
604 | </p> |
---|
605 | |
---|
606 | <blockquote><pre> |
---|
607 | <span class=identifier>BOOST_MULTI_INDEX_MEMBER</span><span class=special>(</span><span class=identifier>A</span><span class=special>,</span><span class=keyword>int</span><span class=special>,</span><span class=identifier>x</span><span class=special>)</span> |
---|
608 | </pre></blockquote> |
---|
609 | |
---|
610 | <p> |
---|
611 | expands by default to |
---|
612 | </p> |
---|
613 | |
---|
614 | <blockquote><pre> |
---|
615 | <span class=identifier>member</span><span class=special><</span><span class=identifier>A</span><span class=special>,</span><span class=keyword>int</span><span class=special>,&</span><span class=identifier>A</span><span class=special>::</span><span class=identifier>x</span><span class=special>></span> |
---|
616 | </pre></blockquote> |
---|
617 | |
---|
618 | <p> |
---|
619 | or alternatively to |
---|
620 | </p> |
---|
621 | |
---|
622 | <blockquote><pre> |
---|
623 | <span class=identifier>member_offset</span><span class=special><</span><span class=identifier>A</span><span class=special>,</span><span class=keyword>int</span><span class=special>,</span><span class=identifier>offsetof</span><span class=special>(</span><span class=identifier>A</span><span class=special>,</span><span class=identifier>x</span><span class=special>)></span> |
---|
624 | </pre></blockquote> |
---|
625 | |
---|
626 | <p> |
---|
627 | if <code>BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS</code> is defined. |
---|
628 | </p> |
---|
629 | |
---|
630 | <h3><a name="mem_fun_explicit">Use of <code>const_mem_fun_explicit</code> and |
---|
631 | <code>mem_fun_explicit</code></a></h3> |
---|
632 | |
---|
633 | <p> |
---|
634 | MSVC++ 6.0 has problems with <code>const</code> member functions as non-type |
---|
635 | template parameters, and thus does not accept the <code>const_mem_fun</code> |
---|
636 | key extractor. A simple workaround, fortunately, has been found, consisting |
---|
637 | in specifying the <i>type</i> of these pointers as an additional template |
---|
638 | parameter. The alternative |
---|
639 | <a href="reference/key_extraction.html#const_mem_fun_explicit"><code>const_mem_fun_explicit</code></a> |
---|
640 | extractor adopts this solution; for instance, given the type |
---|
641 | </p> |
---|
642 | |
---|
643 | <blockquote><pre> |
---|
644 | <span class=keyword>struct</span> <span class=identifier>A</span> |
---|
645 | <span class=special>{</span> |
---|
646 | <span class=keyword>int</span> <span class=identifier>f</span><span class=special>()</span><span class=keyword>const</span><span class=special>;</span> |
---|
647 | <span class=special>};</span> |
---|
648 | </pre></blockquote> |
---|
649 | |
---|
650 | <p> |
---|
651 | the extractor <code>const_mem_fun<A,int,&A::f></code> can be replaced by |
---|
652 | <code>const_mem_fun_explicit<A,int,int (A::*)()const,&A::f></code>. A similar |
---|
653 | <code>mem_fun_explicit</code> class template is provided for non-constant |
---|
654 | member functions. |
---|
655 | </p> |
---|
656 | |
---|
657 | <p> |
---|
658 | If you are writing cross-platform code, the selection of either key extractor |
---|
659 | is transparently handled by the macro |
---|
660 | <a href="reference/key_extraction.html#boost_multi_index_const_mem_fun"><code>BOOST_MULTI_INDEX_CONST_MEM_FUN</code></a>, |
---|
661 | so that |
---|
662 | </p> |
---|
663 | |
---|
664 | <blockquote><pre> |
---|
665 | <span class=identifier>BOOST_MULTI_INDEX_CONST_MEM_FUN</span><span class=special>(</span><span class=identifier>A</span><span class=special>,</span><span class=keyword>int</span><span class=special>,</span><span class=identifier>f</span><span class=special>)</span> |
---|
666 | </pre></blockquote> |
---|
667 | |
---|
668 | <p> |
---|
669 | expands by default to |
---|
670 | </p> |
---|
671 | |
---|
672 | <blockquote><pre> |
---|
673 | <span class=identifier>const_mem_fun</span><span class=special><</span><span class=identifier>A</span><span class=special>,</span><span class=keyword>int</span><span class=special>,&</span><span class=identifier>A</span><span class=special>::</span><span class=identifier>f</span><span class=special>></span> |
---|
674 | </pre></blockquote> |
---|
675 | |
---|
676 | <p> |
---|
677 | but resolves to |
---|
678 | </p> |
---|
679 | |
---|
680 | <blockquote><pre> |
---|
681 | <span class=identifier>const_mem_fun_explicit</span><span class=special><</span><span class=identifier>A</span><span class=special>,</span><span class=keyword>int</span><span class=special>,</span><span class=keyword>int</span> <span class=special>(</span><span class=identifier>A</span><span class=special>::*)()</span><span class=keyword>const</span><span class=special>,&</span><span class=identifier>A</span><span class=special>::</span><span class=identifier>f</span><span class=special>></span> |
---|
682 | </pre></blockquote> |
---|
683 | |
---|
684 | <p> |
---|
685 | in MSVC++ 6.0. Non-<code>const</code> member functions are covered by |
---|
686 | <a href="reference/key_extraction.html#mem_fun_explicit"><code>mem_fun_explicit</code></a> |
---|
687 | and the macro |
---|
688 | <a href="reference/key_extraction.html#boost_multi_index_mem_fun"><code>BOOST_MULTI_INDEX_MEM_FUN</code></a>. |
---|
689 | </p> |
---|
690 | |
---|
691 | <h3><a name="composite_key_no_pts"><code>composite_key</code> in compilers |
---|
692 | without partial template specialization</a></h3> |
---|
693 | |
---|
694 | <p> |
---|
695 | When using <code>composite_key</code>s, lookup is performed by passing |
---|
696 | tuples of values: this ability is achieved by suitably specializing |
---|
697 | the class templates <code>std::equal_to</code>, <code>std::less</code>, |
---|
698 | <code>std::greater</code> and <code>boost::hash</code> for |
---|
699 | <a href="reference/key_extraction.html#composite_key_result"> |
---|
700 | <code>composite_key_result</code></a> instantiations so that they |
---|
701 | provide the appropriate overloads accepting tuples --and in the case |
---|
702 | of <code>std::less</code> and <code>std::greater</code>, also partial |
---|
703 | tuples where only the first components are specified. |
---|
704 | </p> |
---|
705 | |
---|
706 | <p> |
---|
707 | In those compilers that do not support partial template specialization, |
---|
708 | these specializations cannot be provided, and so |
---|
709 | tuple-based lookup is not available by default. In this case, |
---|
710 | <code>multi_index_container</code> instantiations using composite keys |
---|
711 | will work as expected, both for ordered and hashed indices, |
---|
712 | except that lookup operations will not accept tuples as an argument. |
---|
713 | For ordered indices, the most obvious workaround |
---|
714 | to this deficiency involves explicitly specifying the comparison |
---|
715 | predicate with |
---|
716 | <a href="reference/key_extraction.html#composite_key_compare"><code>composite_key_compare</code></a>; |
---|
717 | in the case of hashed indices we can use the analogous |
---|
718 | <a href="reference/key_extraction.html#composite_key_equal_to"><code>composite_key_equal_to</code></a> |
---|
719 | and |
---|
720 | <a href="reference/key_extraction.html#composite_key_hash"><code>composite_key_hash</code></a>. |
---|
721 | This substitution is tedious as the elementary components for all the constituent key extractors must |
---|
722 | be explicitly typed. For this reason, Boost.MultiIndex provides the following replacement |
---|
723 | class templates |
---|
724 | <ul> |
---|
725 | <li><a href="reference/key_extraction.html#composite_key_result_equal_to"> |
---|
726 | <code>composite_key_result_equal_to</code></a>,</li> |
---|
727 | <li><a href="reference/key_extraction.html#composite_key_result_less"> |
---|
728 | <code>composite_key_result_less</code></a>,</li> |
---|
729 | <li><a href="reference/key_extraction.html#composite_key_result_greater"> |
---|
730 | <code>composite_key_result_greater</code></a> and</li> |
---|
731 | <li><a href="reference/key_extraction.html#composite_key_result_hash"> |
---|
732 | <code>composite_key_result_hash</code></a>,</li> |
---|
733 | </ul> |
---|
734 | that act as the missing specializations of <code>std::equal_to</code>, <code>std::less</code>, |
---|
735 | <code>std::greater</code> and <code>boost::hash</code> for <code>composite_key_result</code>s. |
---|
736 | They can be used as follows: |
---|
737 | </p> |
---|
738 | |
---|
739 | <blockquote><pre> |
---|
740 | <span class=keyword>typedef</span> <span class=identifier>composite_key</span><span class=special><</span> |
---|
741 | <span class=identifier>phonebook_entry</span><span class=special>,</span> |
---|
742 | <span class=identifier>member</span><span class=special><</span><span class=identifier>phonebook_entry</span><span class=special>,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,&</span><span class=identifier>phonebook_entry</span><span class=special>::</span><span class=identifier>family_name</span><span class=special>>,</span> |
---|
743 | <span class=identifier>member</span><span class=special><</span><span class=identifier>phonebook_entry</span><span class=special>,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,&</span><span class=identifier>phonebook_entry</span><span class=special>::</span><span class=identifier>given_name</span><span class=special>></span> |
---|
744 | <span class=special>></span> <span class=identifier>ckey_t</span><span class=special>;</span> |
---|
745 | |
---|
746 | <span class=keyword>typedef</span> <span class=identifier>multi_index_container</span><span class=special><</span> |
---|
747 | <span class=identifier>phonebook_entry</span><span class=special>,</span> |
---|
748 | <span class=identifier>indexed_by</span><span class=special><</span> |
---|
749 | <span class=identifier>ordered_non_unique</span><span class=special><</span> |
---|
750 | <span class=identifier>ckey_t</span><span class=special>,</span> |
---|
751 | <span class=comment>// composite_key_result_less plays the role of |
---|
752 | // std::less<ckey_t::result_type></span> |
---|
753 | <span class=identifier>composite_key_result_less</span><span class=special><</span><span class=identifier>ckey_t</span><span class=special>::</span><span class=identifier>result_type</span><span class=special>></span> |
---|
754 | <span class=special>>,</span> |
---|
755 | <span class=identifier>ordered_unique</span><span class=special><</span> |
---|
756 | <span class=identifier>member</span><span class=special><</span><span class=identifier>phonebook_entry</span><span class=special>,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,&</span><span class=identifier>phonebook_entry</span><span class=special>::</span><span class=identifier>phone_number</span><span class=special>></span> |
---|
757 | <span class=special>></span> |
---|
758 | <span class=special>></span> |
---|
759 | <span class=special>></span> <span class=identifier>phonebook</span><span class=special>;</span> |
---|
760 | </pre></blockquote> |
---|
761 | |
---|
762 | <h3><a name="symbol_reduction">Reduction of symbol name lengths</a></h3> |
---|
763 | |
---|
764 | <p> |
---|
765 | The types generated on the instantiations of <code>multi_index_container</code>s |
---|
766 | typically produce very long symbol names, sometimes beyond the internal limits |
---|
767 | of some compilers. There are several techniques to shorten generated symbol |
---|
768 | names: these techniques have also the beneficial side effect that resulting error |
---|
769 | messages are more readable. |
---|
770 | </p> |
---|
771 | |
---|
772 | <h4><a name="argument_limitation">Limitation of maximum number of arguments</a></h4> |
---|
773 | |
---|
774 | <p> |
---|
775 | The class templates <a href="reference/indices.html#indexed_by"><code>indexed_by</code></a>, |
---|
776 | <a href="reference/indices.html#tag"><code>tag</code></a> and |
---|
777 | <a href="reference/key_extraction.html#composite_key"><code>composite_key</code></a> |
---|
778 | accept a variable number of arguments whose maximum number is limited by |
---|
779 | internal macros. Even non-used arguments contribute to the final types, |
---|
780 | so manually adjusting the corresponding macros can result in a modest reduction |
---|
781 | of symbol names. |
---|
782 | </p> |
---|
783 | |
---|
784 | <p align="center"> |
---|
785 | <table cellspacing="0"> |
---|
786 | <caption><b>Limiting maximum number of arguments of some class templates |
---|
787 | of Boost.MultiIndex.</b></caption> |
---|
788 | <tr> |
---|
789 | <th>class template</th> |
---|
790 | <th>limiting macro</th> |
---|
791 | <th>default value</th> |
---|
792 | <th>default value<br>(MSVC++ 6.0)</th> |
---|
793 | </tr> |
---|
794 | <tr> |
---|
795 | <td align="center"> <code>indexed_by</code> </td> |
---|
796 | <td align="center"> <code>BOOST_MULTI_INDEX_LIMIT_INDEXED_BY_SIZE</code> </td> |
---|
797 | <td align="center">20</td> |
---|
798 | <td align="center">5</td> |
---|
799 | </tr> |
---|
800 | <tr class="odd_tr"> |
---|
801 | <td align="center"> <code>tag</code> </td> |
---|
802 | <td align="center"> <code>BOOST_MULTI_INDEX_LIMIT_TAG_SIZE</code> </td> |
---|
803 | <td align="center">20</td> |
---|
804 | <td align="center">3</td> |
---|
805 | </tr> |
---|
806 | <tr> |
---|
807 | <td align="center"> <code>composite_key</code> </td> |
---|
808 | <td align="center"> <code>BOOST_MULTI_INDEX_LIMIT_COMPOSITE_KEY_SIZE</code> </td> |
---|
809 | <td align="center">10</td> |
---|
810 | <td align="center">5</td> |
---|
811 | </tr> |
---|
812 | </table> |
---|
813 | </p> |
---|
814 | |
---|
815 | <h4><a name="type_hiding">Type hiding</a></h4> |
---|
816 | |
---|
817 | <p> |
---|
818 | Consider a typical instantiation of <code>multi_index_container</code>: |
---|
819 | </p> |
---|
820 | |
---|
821 | <blockquote><pre> |
---|
822 | <span class=keyword>typedef</span> <span class=identifier>multi_index_container</span><span class=special><</span> |
---|
823 | <span class=identifier>employee</span><span class=special>,</span> |
---|
824 | <span class=identifier>indexed_by</span><span class=special><</span> |
---|
825 | <span class=identifier>ordered_unique</span><span class=special><</span><span class=identifier>identity</span><span class=special><</span><span class=identifier>employee</span><span class=special>></span> <span class=special>>,</span> |
---|
826 | <span class=identifier>ordered_non_unique</span><span class=special><</span><span class=identifier>member</span><span class=special><</span><span class=identifier>employee</span><span class=special>,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,&</span><span class=identifier>employee</span><span class=special>::</span><span class=identifier>name</span><span class=special>></span> <span class=special>>,</span> |
---|
827 | <span class=identifier>ordered_unique</span><span class=special><</span><span class=identifier>member</span><span class=special><</span><span class=identifier>employee</span><span class=special>,</span><span class=keyword>int</span><span class=special>,&</span><span class=identifier>employee</span><span class=special>::</span><span class=identifier>ssnumber</span><span class=special>></span> <span class=special>></span> |
---|
828 | <span class=special>></span> |
---|
829 | <span class=special>></span> <span class=identifier>employee_set</span><span class=special>;</span> |
---|
830 | </pre></blockquote> |
---|
831 | |
---|
832 | <p> |
---|
833 | Then, for instance, the type <code>employee_set::nth_type<0>::type</code> |
---|
834 | resolves to the following in GCC: |
---|
835 | </p> |
---|
836 | |
---|
837 | <blockquote><pre> |
---|
838 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>::</span><span class=identifier>detail</span><span class=special>::</span><span class=identifier>ordered_index</span><span class=special><</span> |
---|
839 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>::</span><span class=identifier>identity</span><span class=special><</span><span class=identifier>employee</span><span class=special>>,</span> |
---|
840 | <span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special><</span><span class=identifier>employee</span><span class=special>>,</span> |
---|
841 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>::</span><span class=identifier>detail</span><span class=special>::</span><span class=identifier>nth_layer</span><span class=special><</span> |
---|
842 | <span class=number>1</span><span class=special>,</span> <span class=identifier>employee</span><span class=special>,</span> |
---|
843 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>::</span><span class=identifier>indexed_by</span><span class=special><</span> |
---|
844 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>::</span><span class=identifier>ordered_unique</span><span class=special><</span> |
---|
845 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>::</span><span class=identifier>identity</span><span class=special><</span><span class=identifier>employee</span><span class=special>>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span> |
---|
846 | <span class=special>>,</span> |
---|
847 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>::</span><span class=identifier>ordered_non_unique</span><span class=special><</span> |
---|
848 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>::</span><span class=identifier>member</span><span class=special><</span><span class=identifier>employee</span><span class=special>,</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span> <span class=special>&</span><span class=identifier>employee</span><span class=special>::</span><span class=identifier>name</span><span class=special>>,</span> |
---|
849 | <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span> |
---|
850 | <span class=special>>,</span> |
---|
851 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>::</span><span class=identifier>ordered_unique</span><span class=special><</span> |
---|
852 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>::</span><span class=identifier>member</span><span class=special><</span><span class=identifier>employee</span><span class=special>,</span> <span class=keyword>int</span><span class=special>,</span> <span class=special>&</span><span class=identifier>employee</span><span class=special>::</span><span class=identifier>ssnumber</span><span class=special>>,</span> |
---|
853 | <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span> |
---|
854 | <span class=special>>,</span> |
---|
855 | <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> |
---|
856 | <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> |
---|
857 | <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>,</span> <span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span> |
---|
858 | <span class=special>>,</span> |
---|
859 | <span class=identifier>std</span><span class=special>::</span><span class=identifier>allocator</span><span class=special><</span><span class=identifier>employee</span><span class=special>></span> |
---|
860 | <span class=special>>,</span> |
---|
861 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>vector0</span><span class=special><</span><span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>>,</span> |
---|
862 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>::</span><span class=identifier>detail</span><span class=special>::</span><span class=identifier>ordered_unique_tag</span> |
---|
863 | <span class=special>></span> |
---|
864 | </pre></blockquote> |
---|
865 | |
---|
866 | <p> |
---|
867 | It can be seen that a significant portion of the type name is contributed by |
---|
868 | the <code>indexed_by<...></code> part, which is nothing but an expanded |
---|
869 | version of the index specifier list provided in the definition of |
---|
870 | <code>employee_set</code>. We can prevent this very long name from appearing |
---|
871 | in the final type by encapsulating it into another, shorter-named construct: |
---|
872 | </p> |
---|
873 | |
---|
874 | <blockquote><pre> |
---|
875 | <span class=comment>// reducing symbol names through type hiding |
---|
876 | // type hide the index spexifier list within employee_set_indices</span> |
---|
877 | |
---|
878 | <span class=keyword>struct</span> <span class=identifier>employee_set_indices</span><span class=special>:</span> |
---|
879 | <span class=identifier>indexed_by</span><span class=special><</span> |
---|
880 | <span class=identifier>ordered_unique</span><span class=special><</span><span class=identifier>identity</span><span class=special><</span><span class=identifier>employee</span><span class=special>></span> <span class=special>>,</span> |
---|
881 | <span class=identifier>ordered_non_unique</span><span class=special><</span><span class=identifier>member</span><span class=special><</span><span class=identifier>employee</span><span class=special>,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,&</span><span class=identifier>employee</span><span class=special>::</span><span class=identifier>name</span><span class=special>></span> <span class=special>>,</span> |
---|
882 | <span class=identifier>ordered_unique</span><span class=special><</span><span class=identifier>member</span><span class=special><</span><span class=identifier>employee</span><span class=special>,</span><span class=keyword>int</span><span class=special>,&</span><span class=identifier>employee</span><span class=special>::</span><span class=identifier>ssnumber</span><span class=special>></span> <span class=special>></span> |
---|
883 | <span class=special>></span> |
---|
884 | <span class=special>{};</span> |
---|
885 | |
---|
886 | <span class=keyword>typedef</span> <span class=identifier>multi_index_container</span><span class=special><</span> |
---|
887 | <span class=identifier>employee</span><span class=special>,</span> |
---|
888 | <span class=identifier>employee_set_indices</span> |
---|
889 | <span class=special>></span> <span class=identifier>employee_set</span><span class=special>;</span> |
---|
890 | </pre></blockquote> |
---|
891 | |
---|
892 | <p> |
---|
893 | <code>employee_set_indices</code> works as a conventional <code>typedef</code> |
---|
894 | in all respects, save for a detail: its name does not explicitly |
---|
895 | include the information contained in the <code>indexed_by</code> instantiation. |
---|
896 | Applying this technique, <code>employee_set::nth_type<0>::type</code> |
---|
897 | now becomes: |
---|
898 | </p> |
---|
899 | |
---|
900 | <blockquote><pre> |
---|
901 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>::</span><span class=identifier>detail</span><span class=special>::</span><span class=identifier>ordered_index</span><span class=special><</span> |
---|
902 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>::</span><span class=identifier>identity</span><span class=special><</span><span class=identifier>employee</span><span class=special>>,</span> |
---|
903 | <span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special><</span><span class=identifier>employee</span><span class=special>>,</span> |
---|
904 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>::</span><span class=identifier>detail</span><span class=special>::</span><span class=identifier>nth_layer</span><span class=special><</span> |
---|
905 | <span class=number>1</span><span class=special>,</span> <span class=identifier>employee</span><span class=special>,</span> |
---|
906 | <span class=identifier>employee_set_indices</span><span class=special>,</span> |
---|
907 | <span class=identifier>std</span><span class=special>::</span><span class=identifier>allocator</span><span class=special><</span><span class=identifier>employee</span><span class=special>></span> |
---|
908 | <span class=special>>,</span> |
---|
909 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>vector0</span><span class=special><</span><span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>>,</span> |
---|
910 | <span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>::</span><span class=identifier>detail</span><span class=special>::</span><span class=identifier>ordered_unique_tag</span> |
---|
911 | <span class=special>></span> |
---|
912 | </pre></blockquote> |
---|
913 | |
---|
914 | <p> |
---|
915 | which is considerably shorter than the original, and also more |
---|
916 | easily parsed by a human reader. Type hiding would not work if, instead of |
---|
917 | making <code>employee_set_indices</code> a derived <code>struct</code> of |
---|
918 | <code>indexed_by<...></code>, we had defined it as a <code>typedef</code>: |
---|
919 | <code>typedef</code>s are syntactic aliases and usually get expanded |
---|
920 | by the compiler before doing any further type handling. |
---|
921 | </p> |
---|
922 | |
---|
923 | <p> |
---|
924 | Type hiding techniques can also be applied to <code>composite_key</code> intantiations, |
---|
925 | which often contribute a great deal to symbol name lengths. |
---|
926 | </p> |
---|
927 | |
---|
928 | <hr> |
---|
929 | |
---|
930 | <div class="prev_link"><a href="reference/key_extraction.html"><img src="prev.gif" alt="key extraction" border="0"><br> |
---|
931 | Key extraction |
---|
932 | </a></div> |
---|
933 | <div class="up_link"><a href="index.html"><img src="up.gif" alt="index" border="0"><br> |
---|
934 | Index |
---|
935 | </a></div> |
---|
936 | <div class="next_link"><a href="performance.html"><img src="next.gif" alt="performance" border="0"><br> |
---|
937 | Performance |
---|
938 | </a></div><br clear="all" style="clear: all;"> |
---|
939 | |
---|
940 | <br> |
---|
941 | |
---|
942 | <p>Revised October 17th 2005</p> |
---|
943 | |
---|
944 | <p>© Copyright 2003-2005 Joaquín M López Muñoz. |
---|
945 | Distributed under the Boost Software |
---|
946 | License, Version 1.0. (See accompanying file <a href="../../../LICENSE_1_0.txt"> |
---|
947 | LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt"> |
---|
948 | http://www.boost.org/LICENSE_1_0.txt</a>) |
---|
949 | </p> |
---|
950 | |
---|
951 | </body> |
---|
952 | </html> |
---|