Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/multi_index/doc/compiler_specifics.html @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 52.0 KB
Line 
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>
15Key extraction
16</a></div>
17<div class="up_link"><a href="index.html"><img src="up.gif" alt="index" border="0"><br>
18Index
19</a></div>
20<div class="next_link"><a href="performance.html"><img src="next.gif" alt="performance" border="0"><br>
21Performance
22</a></div><br clear="all" style="clear: all;">
23
24<hr>
25
26<p>
27Boost.MultiIndex has been tried in different compilers, with
28various degrees of success. We list the limitations encountered,
29along 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>
79Currently, Boost.MultiIndex cannot be used with BCB 6.4. The
80number of problems encountered during the tests makes it unlikely that
81future versions of the library can be made to work under
82this 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>
88No problems have been detected with this compiler. The library fails to compile,
89however, 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>
95No problems have been detected with this compiler. Versions 6.5-042,
967.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>
102No problems have been detected with several versions of this compiler
103starting 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>
122Boost.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>
128On this platform, GCC is not able to handle debug symbol names whose length
129exceeds 32,768 bytes, resulting in the error <code>mips-tfile, ... string
130too big</code>. You may encounter this issue with heavily templatized
131code like Boost.MultiIndex, which typically produces long symbol names. The problem
132can be overcome by omitting the compiler option <code>-g</code> (generate debugging
133information.) Alternatively, consult the section on
134<a href="#symbol_reduction">reduction of symbol name lengths</a> for various
135applicable workarounds.
136</p>
137
138<h3><a name="gcc_4_darwin">Darwin GCC 4.0</a></h3>
139
140<p>
141Build 4061 of GCC 4.0, shipped with Darwin 8.2 and prior (Mac OS X 10.4.2 and
142prior), corresponds to a prerelease version of GNU GCC 4.0.0 which introduces
143a <a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17435">regression bug</a>
144related to binding of references to temporary objects. This bug precludes the
145usage of Boost.MultiIndex
146<a href="advanced_topics.html#invariant_check">invariant-checking mode</a>; other
147than this, Boost.MultiIndex works correctly.
148The bug is corrected in GCC 4.0 Apple build 5026, which is in sync with the official
149release of GNU GCC 4.0.0, so the invariant-checking mode is available from this
150upgrade.
151</p>
152
153<h2><a name="acc_60">HP aC++ A.06.00 for HP-UX</a></h2>
154
155<p>
156No 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,
163refer 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
166use of <code>offsetof</code> with non-POD types: these warnings can be suppressed
167by setting the compiler option <code>-qsuppress=1540-1281</code>, or, alternatively,
168by 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>
176This latter pragma, however, may also eliminate other warnings not related
177to the use of <code>offsetof</code>.
178</p>
179
180<blockquote><hr></blockquote>
181
182<p>
183Serialization capabilities are not available as Boost.Serialization is not
184supported 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>
190No 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
194for Linux</a></h2>
195
196<p>
197No 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,
204refer 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>
211When used on top of MSVC++ 7.0 or prior, argument dependent lookup is
212disabled by default. This will cause problems with many Boost libraries,
213and in particular with the serialization part of Boost.MultiIndex.
214Argument 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">
219Intel C++ Compiler for Windows 32-bit 7.1 + STLport 4.5.3</a></h2>
220
221<p>
222Boost.MultiIndex works for this configuration. The same limitations apply as
223in Intel C++ 7.1 with its original Dinkumware standard library. STLport 4.6.2 has
224also 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>
230When used on top of MSVC++ 7.0 or prior, argument dependent lookup is
231disabled by default. This will cause problems with many Boost libraries,
232and in particular with the serialization part of Boost.MultiIndex.
233Argument dependent lookup is enabled by adding
234<code>/Qoption,c,--arg_dep_lookup</code> to the project options.
235Other than this, Boost.MultiIndex works without problems. Compiler versions
236from 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>
242Boost.MultiIndex works correctly with versions of this compiler from 8.3 to
2439.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,
250refer 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>
257not 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>
265No support for <a href="reference/multi_index_container.html#index_retrieval">index retrieval</a>
266and <a href="reference/multi_index_container.html#projection">projection</a>
267nested 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>
278You can use instead their global equivalents. Also, this compiler does not
279implement argument dependent lookup, so you might need to explicitly qualify
280these 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.
288MSVC++ 6.0, however, does not properly handle this import. So, instead of
289writing:
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>&lt;...&gt;</span>
294</pre></blockquote>
295
296<p>
297use 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>&lt;...&gt;</span>
302</pre></blockquote>
303
304<p>
305or else resort to a directive <code>using namespace boost::multi_index</code>.
306</p>
307
308<blockquote><hr></blockquote>
309
310<p>
311The lack of partial template specialization support in MSVC++ 6.0
312results in some inconveniences when using <code>composite_key</code> that
313can be remedied as explained in
314<a href="#composite_key_no_pts">"<code>composite_key</code>
315in compilers without partial template specialization"</a>.
316</p>
317
318<blockquote><hr></blockquote>
319
320<p>
321MSVC++ 6.0 presents serious limitations for the maximum length of
322symbol names generated by the compiler, which might result in the
323linker error
324<code><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/lnk1179.asp">LNK1179</a>:
325invalid or corrupt file: duplicate comdat
326comdat</code>. To overcome this problem, consult the section on
327<a href="#symbol_reduction">reduction of symbol name lengths</a> for various
328applicable workarounds.
329</p>
330
331<blockquote><hr></blockquote>
332
333<p>
334Under 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
337default parameter</code>, inside the MSVC internal header
338<code>&lt;xlocnum></code>.
339This problem is a recurrent bug of the compiler, and has been reported in
340other 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>.
346The error is triggered, though not in a systematic manner, by the use
347of <code>multi_index_container</code> iterator constructor. Two workarounds exist:
348the first consists of avoiding this constructor and replacing
349code like:
350</p>
351
352<blockquote><pre>
353<span class=identifier>multi_index_container</span><span class=special>&lt;...&gt;</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>
357with equivalent operations:
358</p>
359
360<blockquote><pre>
361<span class=identifier>multi_index_container</span><span class=special>&lt;...&gt;</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>
366The second workaround has not been confirmed by the author, but it is given
367on the Internet in connection with this error appearing in other libraries.
368Replace line 84 of <code>&lt;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>
375with 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
384replacement can result in unexpected side effects in code implicitly
385using <code>&lt;xlocnum></code>.
386</p>
387
388<blockquote><hr></blockquote>
389
390<p>
391In general, the extensive use of templates by Boost.MultiIndex puts this compiler
392under severe stress, so that several internal limitations may be reached.
393The 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>
418Boost.MultiIndex works for this configuration. The same limitations apply as
419in MSVC++ 6.0 with its original Dinkumware standard library. STLport 4.6.2 has
420also been confirmed to work correctly.
421</p>
422
423<blockquote><hr></blockquote>
424
425<p>
426It is not possible to use the serialization capabilities of Boost.MultiIndex
427along with the dynamic version of STLport, as some linking errors result.
428Use instead the static version of STLport. This bug is reportedly fixed in
429STLport 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,
436refer 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>
443No support for <a href="reference/multi_index_container.html#index_retrieval">index retrieval</a>
444and <a href="reference/multi_index_container.html#projection">projection</a>
445nested 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>
456You can use instead their global equivalents. Also, this compiler does not
457implement argument dependent lookup, so you might need to explicitly qualify
458these 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.
466MSVC++ 7.0, however, does not properly handle this import. So, instead of
467writing:
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>&lt;...&gt;</span>
472</pre></blockquote>
473
474<p>
475use 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>&lt;...&gt;</span>
480</pre></blockquote>
481
482<p>
483or else resort to a directive <code>using namespace boost::multi_index</code>.
484</p>
485
486<blockquote><hr></blockquote>
487
488<p>
489The lack of partial template specialization support in MSVC++ 7.0
490results in some inconveniences when using <code>composite_key</code> that
491can be remedied as explained in
492<a href="#composite_key_no_pts">"<code>composite_key</code>
493in 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>
499Problems have been reported when compiling the library with the <code>/Gm</code>
500option (Enable Minimal Rebuild.) Seemingly, this is due to an
501internal defect of the compiler (see for instance
502<a href="http://lists.boost.org/MailArchives/boost-users/msg05988.php">
503this mention of a similar issue</a> in the Boost Users mailing list.)
504If <code>/Gm</code> is turned off, Boost.MultiIndex compiles and runs
505without 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>
511Boost.MultiIndex works for this configuration. The same issues apply as in
512MSVC++ 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>
518No problems have been detected with this compiler. The Beta 2 version of
519this 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>
527The <code>member</code> key extractor poses some problems in compilers
528that do not properly support pointers to members as non-type
529template arguments, as indicated by the
530<a href="../../../libs/config/config.htm">Boost Configuration Library</a>
531defect macro <code>BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS</code>.
532The following compilers have been confirmed not
533to 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>
539This program can help determine if your compiler
540properly supports pointers to members as non-type template parameters:
541</p>
542
543<blockquote><pre>
544<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>iostream</span><span class=special>&gt;</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>&lt;</span><span class=keyword>int</span> <span class=identifier>pair</span><span class=special>::*</span> <span class=identifier>PtrToPairMember</span><span class=special>&gt;</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>&amp;</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>&lt;&amp;</span><span class=identifier>pair</span><span class=special>::</span><span class=identifier>x</span><span class=special>&gt;</span> <span class=identifier>fx</span><span class=special>;</span>
563  <span class=identifier>foo</span><span class=special>&lt;&amp;</span><span class=identifier>pair</span><span class=special>::</span><span class=identifier>y</span><span class=special>&gt;</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>&lt;&lt;</span><span class=string>&quot;KO&quot;</span><span class=special>&lt;&lt;</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>&lt;&lt;</span><span class=string>&quot;OK&quot;</span><span class=special>&lt;&lt;</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>
574If 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,
576please 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>
580has been provided that does the work of <code>member</code> at the
581expense of less convenient notation and the possibility of
582non-conformance with the standard. Please consult
583the reference for further information on <code>member_offset</code>.
584As 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>
595the instantiation <code>member&lt;A,int,&amp;A::x></code> can be simulated then
596as <code>member_offset&lt;A,int,offsetof(A,x)></code>.
597</p>
598
599<p>
600For 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>.
602Continuing with the example above, the
603expression
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>
611expands by default to
612</p>
613
614<blockquote><pre>
615<span class=identifier>member</span><span class=special>&lt;</span><span class=identifier>A</span><span class=special>,</span><span class=keyword>int</span><span class=special>,&amp;</span><span class=identifier>A</span><span class=special>::</span><span class=identifier>x</span><span class=special>&gt;</span>
616</pre></blockquote>
617
618<p>
619or alternatively to
620</p>
621
622<blockquote><pre>
623<span class=identifier>member_offset</span><span class=special>&lt;</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>)&gt;</span>
624</pre></blockquote>
625
626<p>
627if <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>
634MSVC++ 6.0 has problems with <code>const</code> member functions as non-type
635template parameters, and thus does not accept the <code>const_mem_fun</code>
636key extractor. A simple workaround, fortunately, has been found, consisting
637in specifying the <i>type</i> of these pointers as an additional template
638parameter. The alternative
639<a href="reference/key_extraction.html#const_mem_fun_explicit"><code>const_mem_fun_explicit</code></a>
640extractor 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>
651the extractor <code>const_mem_fun&lt;A,int,&amp;A::f></code> can be replaced by
652<code>const_mem_fun_explicit&lt;A,int,int (A::*)()const,&amp;A::f></code>. A similar
653<code>mem_fun_explicit</code> class template is provided for non-constant
654member functions.
655</p>
656
657<p>
658If you are writing cross-platform code, the selection of either key extractor
659is 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>,
661so 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>
669expands by default to
670</p>
671
672<blockquote><pre>
673<span class=identifier>const_mem_fun</span><span class=special>&lt;</span><span class=identifier>A</span><span class=special>,</span><span class=keyword>int</span><span class=special>,&amp;</span><span class=identifier>A</span><span class=special>::</span><span class=identifier>f</span><span class=special>&gt;</span>
674</pre></blockquote>
675
676<p>
677but resolves to
678</p>
679
680<blockquote><pre>
681<span class=identifier>const_mem_fun_explicit</span><span class=special>&lt;</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>,&amp;</span><span class=identifier>A</span><span class=special>::</span><span class=identifier>f</span><span class=special>&gt;</span>
682</pre></blockquote>
683
684<p>
685in 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>
687and 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
692without partial template specialization</a></h3>
693
694<p>
695When using <code>composite_key</code>s, lookup is performed by passing
696tuples of values: this ability is achieved by suitably specializing
697the 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
701provide the appropriate overloads accepting tuples --and in the case
702of <code>std::less</code> and <code>std::greater</code>, also partial
703tuples where only the first components are specified.
704</p>
705
706<p>
707In those compilers that do not support partial template specialization,
708these specializations cannot be provided, and so
709tuple-based lookup is not available by default. In this case,
710<code>multi_index_container</code> instantiations using composite keys
711will work as expected, both for ordered and hashed indices,
712except that lookup operations will not accept tuples as an argument.
713For ordered indices, the most obvious workaround
714to this deficiency involves explicitly specifying the comparison
715predicate with
716<a href="reference/key_extraction.html#composite_key_compare"><code>composite_key_compare</code></a>;
717in 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>
719and
720<a href="reference/key_extraction.html#composite_key_hash"><code>composite_key_hash</code></a>.
721This substitution is tedious as the elementary components for all the constituent key extractors must
722be explicitly typed. For this reason, Boost.MultiIndex provides the following replacement
723class 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>
734that 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.
736They 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>&lt;</span>
741  <span class=identifier>phonebook_entry</span><span class=special>,</span>
742  <span class=identifier>member</span><span class=special>&lt;</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>,&amp;</span><span class=identifier>phonebook_entry</span><span class=special>::</span><span class=identifier>family_name</span><span class=special>&gt;,</span>
743  <span class=identifier>member</span><span class=special>&lt;</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>,&amp;</span><span class=identifier>phonebook_entry</span><span class=special>::</span><span class=identifier>given_name</span><span class=special>&gt;</span>
744<span class=special>&gt;</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>&lt;</span>
747  <span class=identifier>phonebook_entry</span><span class=special>,</span>
748  <span class=identifier>indexed_by</span><span class=special>&lt;</span>
749    <span class=identifier>ordered_non_unique</span><span class=special>&lt;</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&lt;ckey_t::result_type&gt;</span>
753      <span class=identifier>composite_key_result_less</span><span class=special>&lt;</span><span class=identifier>ckey_t</span><span class=special>::</span><span class=identifier>result_type</span><span class=special>&gt;</span>
754    <span class=special>&gt;,</span>
755    <span class=identifier>ordered_unique</span><span class=special>&lt;</span>
756      <span class=identifier>member</span><span class=special>&lt;</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>,&amp;</span><span class=identifier>phonebook_entry</span><span class=special>::</span><span class=identifier>phone_number</span><span class=special>&gt;</span>
757    <span class=special>&gt;</span>
758  <span class=special>&gt;</span>
759<span class=special>&gt;</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>
765The types generated on the instantiations of <code>multi_index_container</code>s
766typically produce very long symbol names, sometimes beyond the internal limits
767of some compilers. There are several techniques to shorten generated symbol
768names: these techniques have also the beneficial side effect that resulting error
769messages are more readable.
770</p>
771
772<h4><a name="argument_limitation">Limitation of maximum number of arguments</a></h4>
773
774<p>
775The 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>
778accept a variable number of arguments whose maximum number is limited by
779internal macros. Even non-used arguments contribute to the final types,
780so manually adjusting the corresponding macros can result in a modest reduction
781of 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">&nbsp;<code>indexed_by</code>&nbsp;</td>
796  <td align="center">&nbsp;<code>BOOST_MULTI_INDEX_LIMIT_INDEXED_BY_SIZE</code>&nbsp;</td>
797  <td align="center">20</td>
798  <td align="center">5</td>
799</tr>
800<tr class="odd_tr">
801  <td align="center">&nbsp;<code>tag</code>&nbsp;</td>
802  <td align="center">&nbsp;<code>BOOST_MULTI_INDEX_LIMIT_TAG_SIZE</code>&nbsp;</td>
803  <td align="center">20</td>
804  <td align="center">3</td>
805</tr>
806<tr>
807  <td align="center">&nbsp;<code>composite_key</code>&nbsp;</td>
808  <td align="center">&nbsp;<code>BOOST_MULTI_INDEX_LIMIT_COMPOSITE_KEY_SIZE</code>&nbsp;</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>
818Consider 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>&lt;</span>
823  <span class=identifier>employee</span><span class=special>,</span>
824  <span class=identifier>indexed_by</span><span class=special>&lt;</span>
825    <span class=identifier>ordered_unique</span><span class=special>&lt;</span><span class=identifier>identity</span><span class=special>&lt;</span><span class=identifier>employee</span><span class=special>&gt;</span> <span class=special>&gt;,</span>
826    <span class=identifier>ordered_non_unique</span><span class=special>&lt;</span><span class=identifier>member</span><span class=special>&lt;</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>,&amp;</span><span class=identifier>employee</span><span class=special>::</span><span class=identifier>name</span><span class=special>&gt;</span> <span class=special>&gt;,</span>
827    <span class=identifier>ordered_unique</span><span class=special>&lt;</span><span class=identifier>member</span><span class=special>&lt;</span><span class=identifier>employee</span><span class=special>,</span><span class=keyword>int</span><span class=special>,&amp;</span><span class=identifier>employee</span><span class=special>::</span><span class=identifier>ssnumber</span><span class=special>&gt;</span> <span class=special>&gt;</span>
828  <span class=special>&gt;</span>
829<span class=special>&gt;</span> <span class=identifier>employee_set</span><span class=special>;</span>
830</pre></blockquote>
831
832<p>
833Then, for instance, the type <code>employee_set::nth_type&lt;0&gt;::type</code>
834resolves 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>&lt;</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>&lt;</span><span class=identifier>employee</span><span class=special>&gt;,</span>
840  <span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special>&lt;</span><span class=identifier>employee</span><span class=special>&gt;,</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>&lt;</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>&lt;</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>&lt;</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>&lt;</span><span class=identifier>employee</span><span class=special>&gt;,</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>&gt;,</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>&lt;</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>&lt;</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>&amp;</span><span class=identifier>employee</span><span class=special>::</span><span class=identifier>name</span><span class=special>&gt;,</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>&gt;,</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>&lt;</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>&lt;</span><span class=identifier>employee</span><span class=special>,</span> <span class=keyword>int</span><span class=special>,</span> <span class=special>&amp;</span><span class=identifier>employee</span><span class=special>::</span><span class=identifier>ssnumber</span><span class=special>&gt;,</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>&gt;,</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>&gt;,</span>
859    <span class=identifier>std</span><span class=special>::</span><span class=identifier>allocator</span><span class=special>&lt;</span><span class=identifier>employee</span><span class=special>&gt;</span>
860  <span class=special>&gt;,</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>&lt;</span><span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>&gt;,</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>&gt;</span>
864</pre></blockquote>
865
866<p>
867It can be seen that a significant portion of the type name is contributed by
868the <code>indexed_by&lt;...&gt;</code> part, which is nothing but an expanded
869version of the index specifier list provided in the definition of
870<code>employee_set</code>. We can prevent this very long name from appearing
871in 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>&lt;</span>
880    <span class=identifier>ordered_unique</span><span class=special>&lt;</span><span class=identifier>identity</span><span class=special>&lt;</span><span class=identifier>employee</span><span class=special>&gt;</span> <span class=special>&gt;,</span>
881    <span class=identifier>ordered_non_unique</span><span class=special>&lt;</span><span class=identifier>member</span><span class=special>&lt;</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>,&amp;</span><span class=identifier>employee</span><span class=special>::</span><span class=identifier>name</span><span class=special>&gt;</span> <span class=special>&gt;,</span>
882    <span class=identifier>ordered_unique</span><span class=special>&lt;</span><span class=identifier>member</span><span class=special>&lt;</span><span class=identifier>employee</span><span class=special>,</span><span class=keyword>int</span><span class=special>,&amp;</span><span class=identifier>employee</span><span class=special>::</span><span class=identifier>ssnumber</span><span class=special>&gt;</span> <span class=special>&gt;</span>
883  <span class=special>&gt;</span>
884<span class=special>{};</span>
885
886<span class=keyword>typedef</span> <span class=identifier>multi_index_container</span><span class=special>&lt;</span>
887  <span class=identifier>employee</span><span class=special>,</span>
888  <span class=identifier>employee_set_indices</span>
889<span class=special>&gt;</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>
894in all respects, save for a detail: its name does not explicitly
895include the information contained in the <code>indexed_by</code> instantiation.
896Applying this technique, <code>employee_set::nth_type&lt;0&gt;::type</code>
897now 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>&lt;</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>&lt;</span><span class=identifier>employee</span><span class=special>&gt;,</span>
903  <span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special>&lt;</span><span class=identifier>employee</span><span class=special>&gt;,</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>&lt;</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>&lt;</span><span class=identifier>employee</span><span class=special>&gt;</span>
908  <span class=special>&gt;,</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>&lt;</span><span class=identifier>mpl_</span><span class=special>::</span><span class=identifier>na</span><span class=special>&gt;,</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>&gt;</span>
912</pre></blockquote>
913
914<p>
915which is considerably shorter than the original, and also more
916easily parsed by a human reader. Type hiding would not work if, instead of
917making <code>employee_set_indices</code> a derived <code>struct</code> of
918<code>indexed_by&lt;...&gt;</code>, we had defined it as a <code>typedef</code>:
919<code>typedef</code>s are syntactic aliases and usually get expanded
920by the compiler before doing any further type handling.
921</p>
922
923<p>
924Type hiding techniques can also be applied to <code>composite_key</code> intantiations,
925which 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>
931Key extraction
932</a></div>
933<div class="up_link"><a href="index.html"><img src="up.gif" alt="index" border="0"><br>
934Index
935</a></div>
936<div class="next_link"><a href="performance.html"><img src="next.gif" alt="performance" border="0"><br>
937Performance
938</a></div><br clear="all" style="clear: all;">
939
940<br>
941
942<p>Revised October 17th 2005</p>
943
944<p>&copy; Copyright 2003-2005 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;oz.
945Distributed under the Boost Software
946License, Version 1.0. (See accompanying file <a href="../../../LICENSE_1_0.txt">
947LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
948http://www.boost.org/LICENSE_1_0.txt</a>)
949</p>
950
951</body>
952</html>
Note: See TracBrowser for help on using the repository browser.