• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Complete instantiation scheme</title>
5<link rel="stylesheet" href="../../boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../index.html" title="Chapter 1. Boost.Bimap">
8<link rel="up" href="../the_tutorial.html" title="The tutorial">
9<link rel="prev" href="additional_information.html" title="Additional information">
10<link rel="next" href="../bimap_and_boost.html" title="Bimap and Boost">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="additional_information.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../bimap_and_boost.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h3 class="title">
27<a name="boost_bimap.the_tutorial.complete_instantiation_scheme"></a><a class="link" href="complete_instantiation_scheme.html" title="Complete instantiation scheme">Complete
28      instantiation scheme</a>
29</h3></div></div></div>
30<p>
31        To summarize, this is the complete instantiation scheme.
32      </p>
33<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bimap</span>
34<span class="special">&lt;</span>
35    <span class="identifier">LeftCollectionType</span><span class="special">,</span> <span class="identifier">RightCollectionType</span>
36
37    <span class="special">[</span> <span class="special">,</span> <span class="identifier">SetTypeOfRelation</span>  <span class="special">]</span>  <span class="comment">// Default to left_based</span>
38    <span class="special">[</span> <span class="special">,</span> <span class="identifier">with_info</span><span class="special">&lt;</span> <span class="identifier">Info</span> <span class="special">&gt;</span>  <span class="special">]</span>  <span class="comment">// Default to no info</span>
39    <span class="special">[</span> <span class="special">,</span> <span class="identifier">Allocator</span>          <span class="special">]</span>  <span class="comment">// Default to std::allocator&lt;&gt;</span>
40
41<span class="special">&gt;</span> <span class="identifier">bm</span><span class="special">;</span>
42</pre>
43<p>
44        <code class="computeroutput"><span class="special">{</span><span class="identifier">Side</span><span class="special">}</span><span class="identifier">CollectionType</span></code>
45        can directly be a type. This defaults to <code class="computeroutput"><span class="identifier">set_of</span><span class="special">&lt;</span><span class="identifier">Type</span><span class="special">&gt;</span></code>, or can be a <code class="computeroutput"><span class="special">{</span><span class="identifier">CollectionType</span><span class="special">}</span><span class="identifier">_of</span><span class="special">&lt;</span><span class="identifier">Type</span><span class="special">&gt;</span></code>
46        specification. Additionally, the type of this two parameters can be tagged
47        to specify user defined names instead of the usual <code class="computeroutput"><span class="identifier">member_at</span><span class="special">::-</span><span class="identifier">Side</span><span class="special">-</span></code> tags.
48      </p>
49<p>
50        The possible way to use the first parameter are:
51      </p>
52<pre class="programlisting"><span class="identifier">bimap</span><span class="special">&lt;</span> <span class="identifier">Type</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">&gt;</span>
53</pre>
54<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
55<li class="listitem">
56            Left type: <code class="computeroutput"><span class="identifier">Type</span></code>
57          </li>
58<li class="listitem">
59            Left collection type: <code class="computeroutput"><span class="identifier">set_of</span><span class="special">&lt;</span> <span class="identifier">Type</span>
60            <span class="special">&gt;</span></code>
61          </li>
62<li class="listitem">
63            Left tag: <code class="computeroutput"><span class="identifier">member_at</span><span class="special">::</span><span class="identifier">left</span></code>
64          </li>
65</ul></div>
66<pre class="programlisting"><span class="identifier">bimap</span><span class="special">&lt;</span> <span class="special">{</span><span class="identifier">CollectionType</span><span class="special">}</span><span class="identifier">_of</span><span class="special">&lt;</span> <span class="identifier">Type</span> <span class="special">&gt;,</span> <span class="identifier">R</span> <span class="special">&gt;</span>
67</pre>
68<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
69<li class="listitem">
70            Left type: <code class="computeroutput"><span class="identifier">Type</span></code>
71          </li>
72<li class="listitem">
73            Left collection type: <code class="computeroutput"><span class="special">{</span><span class="identifier">CollectionType</span><span class="special">}</span><span class="identifier">_of</span><span class="special">&lt;</span> <span class="identifier">LeftType</span> <span class="special">&gt;</span></code>
74          </li>
75<li class="listitem">
76            Left tag: <code class="computeroutput"><span class="identifier">member_at</span><span class="special">::</span><span class="identifier">left</span></code>
77          </li>
78</ul></div>
79<pre class="programlisting"><span class="identifier">bimap</span><span class="special">&lt;</span> <span class="identifier">tagged</span><span class="special">&lt;</span> <span class="identifier">Type</span><span class="special">,</span> <span class="identifier">Tag</span> <span class="special">&gt;,</span> <span class="identifier">R</span> <span class="special">&gt;</span>
80</pre>
81<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
82<li class="listitem">
83            Left type: <code class="computeroutput"><span class="identifier">Type</span></code>
84          </li>
85<li class="listitem">
86            Left collection type: <code class="computeroutput"><span class="identifier">set_of</span><span class="special">&lt;</span> <span class="identifier">LeftType</span>
87            <span class="special">&gt;</span></code>
88          </li>
89<li class="listitem">
90            Left tag: <code class="computeroutput"><span class="identifier">Tag</span></code>
91          </li>
92</ul></div>
93<pre class="programlisting"><span class="identifier">bimap</span><span class="special">&lt;</span> <span class="special">{</span><span class="identifier">CollectionType</span><span class="special">}</span><span class="identifier">_of</span><span class="special">&lt;</span> <span class="identifier">tagged</span><span class="special">&lt;</span> <span class="identifier">Type</span><span class="special">,</span> <span class="identifier">Tag</span> <span class="special">&gt;</span> <span class="special">&gt;,</span> <span class="identifier">R</span> <span class="special">&gt;</span>
94</pre>
95<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
96<li class="listitem">
97            Left type: <code class="computeroutput"><span class="identifier">Type</span></code>
98          </li>
99<li class="listitem">
100            Left collection type: <code class="computeroutput"><span class="special">{</span><span class="identifier">CollectionType</span><span class="special">}</span><span class="identifier">_of</span><span class="special">&lt;</span> <span class="identifier">LeftType</span> <span class="special">&gt;</span></code>
101          </li>
102<li class="listitem">
103            Left tag: <code class="computeroutput"><span class="identifier">Tag</span></code>
104          </li>
105</ul></div>
106<p>
107        The same options are available for the second parameter.
108      </p>
109<p>
110        The last three parameters are used to specify the collection type of the
111        relation, the information member and the allocator type.
112      </p>
113<p>
114        If you want to specify a custom allocator type while relying on the default
115        value of CollectionTypeOfRelation, you can do so by simply writing <code class="computeroutput"><span class="identifier">bimap</span><span class="special">&lt;</span><span class="identifier">LeftKeyType</span><span class="special">,</span>
116        <span class="identifier">RightKeyType</span><span class="special">,</span>
117        <span class="identifier">Allocator</span><span class="special">&gt;</span></code>.
118        Boost.Bimap's internal machinery detects that the third parameter in this
119        case does not refer to the relation type but rather to an allocator.
120      </p>
121<p>
122        The following are the possible ways of instantiating the last three parameters
123        of a bimap. You can ignore some of the parameter but the order must be respected.
124      </p>
125<pre class="programlisting"><span class="identifier">bimap</span><span class="special">&lt;</span> <span class="identifier">L</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">&gt;</span>
126</pre>
127<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
128<li class="listitem">
129            set_of_relation_type: based on the left key type
130          </li>
131<li class="listitem">
132            info: no info
133          </li>
134<li class="listitem">
135            allocator: std::allocator
136          </li>
137</ul></div>
138<pre class="programlisting"><span class="identifier">bimap</span><span class="special">&lt;</span> <span class="identifier">L</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">,</span><span class="identifier">SetOfRelationType</span><span class="special">&gt;</span>
139</pre>
140<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
141<li class="listitem">
142            set_of_relation_type: SetOfRelationType
143          </li>
144<li class="listitem">
145            info: no info
146          </li>
147<li class="listitem">
148            allocator: std::allocator
149          </li>
150</ul></div>
151<pre class="programlisting"><span class="identifier">bimap</span><span class="special">&lt;</span> <span class="identifier">L</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">,</span> <span class="identifier">SetOfRelationType</span><span class="special">,</span> <span class="identifier">with_info</span><span class="special">&lt;</span><span class="identifier">Info</span><span class="special">&gt;</span> <span class="special">&gt;</span>
152</pre>
153<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
154<li class="listitem">
155            set_of_relation_type: SetOfRelationType
156          </li>
157<li class="listitem">
158            info: Info
159          </li>
160<li class="listitem">
161            allocator: std::allocator
162          </li>
163</ul></div>
164<pre class="programlisting"><span class="identifier">bimap</span><span class="special">&lt;</span> <span class="identifier">L</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">,</span> <span class="identifier">SetOfRelationType</span><span class="special">,</span> <span class="identifier">with_info</span><span class="special">&lt;</span><span class="identifier">Info</span><span class="special">&gt;,</span> <span class="identifier">Allocator</span><span class="special">&gt;</span>
165</pre>
166<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
167<li class="listitem">
168            set_of_relation_type: SetOfRelationType
169          </li>
170<li class="listitem">
171            info: Info
172          </li>
173<li class="listitem">
174            allocator: Allocator
175          </li>
176</ul></div>
177<pre class="programlisting"><span class="identifier">bimap</span><span class="special">&lt;</span> <span class="identifier">L</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">,</span> <span class="identifier">SetOfRelationType</span><span class="special">,</span> <span class="identifier">Allocator</span><span class="special">&gt;</span>
178</pre>
179<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
180<li class="listitem">
181            set_of_relation_type: SetOfRelationType
182          </li>
183<li class="listitem">
184            info: no info
185          </li>
186<li class="listitem">
187            allocator: Allocator
188          </li>
189</ul></div>
190<pre class="programlisting"><span class="identifier">bimap</span><span class="special">&lt;</span> <span class="identifier">L</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">,</span> <span class="identifier">with_info</span><span class="special">&lt;</span><span class="identifier">Info</span><span class="special">&gt;</span> <span class="special">&gt;</span>
191</pre>
192<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
193<li class="listitem">
194            set_of_relation_type: based on the left key type
195          </li>
196<li class="listitem">
197            info: Info
198          </li>
199<li class="listitem">
200            allocator: std::allocator
201          </li>
202</ul></div>
203<pre class="programlisting"><span class="identifier">bimap</span><span class="special">&lt;</span> <span class="identifier">L</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">,</span> <span class="identifier">with_info</span><span class="special">&lt;</span><span class="identifier">Info</span><span class="special">&gt;,</span> <span class="identifier">Allocator</span><span class="special">&gt;</span>
204</pre>
205<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
206<li class="listitem">
207            set_of_relation_type: based on the left key type
208          </li>
209<li class="listitem">
210            allocator: Allocator
211          </li>
212</ul></div>
213<pre class="programlisting"><span class="identifier">bimap</span><span class="special">&lt;</span> <span class="identifier">L</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">,</span> <span class="identifier">Allocator</span><span class="special">&gt;</span>
214</pre>
215<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
216<li class="listitem">
217            set_of_relation_type: based on the left key type
218          </li>
219<li class="listitem">
220            info: no info
221          </li>
222<li class="listitem">
223            allocator: Allocator
224          </li>
225</ul></div>
226</div>
227<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
228<td align="left"></td>
229<td align="right"><div class="copyright-footer">Copyright © 2006-2012 Matias Capeletto<p>
230        Distributed under the Boost Software License, Version 1.0. (See accompanying
231        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
232      </p>
233</div></td>
234</tr></table>
235<hr>
236<div class="spirit-nav">
237<a accesskey="p" href="additional_information.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../bimap_and_boost.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
238</div>
239</body>
240</html>
241