rationale.html 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Rationale</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&#160;1.&#160;Boost.Bimap">
  8. <link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Bimap">
  9. <link rel="prev" href="release_notes.html" title="Release notes">
  10. <link rel="next" href="rationale/additional_features.html" title="Additional Features">
  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="release_notes.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.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="rationale/additional_features.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
  24. </div>
  25. <div class="section">
  26. <div class="titlepage"><div><div><h2 class="title" style="clear: both">
  27. <a name="boost_bimap.rationale"></a><a class="link" href="rationale.html" title="Rationale">Rationale</a>
  28. </h2></div></div></div>
  29. <div class="toc"><dl class="toc">
  30. <dt><span class="section"><a href="rationale.html#boost_bimap.rationale.general_design">General Design</a></span></dt>
  31. <dt><span class="section"><a href="rationale/additional_features.html">Additional
  32. Features</a></span></dt>
  33. <dt><span class="section"><a href="rationale/code.html">Code</a></span></dt>
  34. <dt><span class="section"><a href="rationale/the_student_and_the_mentor.html">The
  35. student and the mentor</a></span></dt>
  36. </dl></div>
  37. <p>
  38. This section assumes that you have read all other sections, the most of important
  39. of which being <span class="emphasis"><em>tutorial</em></span>, <span class="emphasis"><em>std::set theory</em></span>
  40. and the <span class="emphasis"><em>reference</em></span>, and that you have tested the library.
  41. A lot of effort was invested in making the interface as intuitive and clean
  42. as possible. If you understand, and hopefully like, the interface of this library,
  43. it will be a lot easier to read this rationale. The following section is little
  44. more than a rationale. This library was coded in the context of the Google
  45. SoC 2006 and the student and mentor were in different continents. A great deal
  46. of email flowed between Joaquin and Matias. The juiciest parts of the conversations
  47. where extracted and rearranged here.
  48. </p>
  49. <div class="note"><table border="0" summary="Note">
  50. <tr>
  51. <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
  52. <th align="left">Note</th>
  53. </tr>
  54. <tr><td align="left" valign="top"><p>
  55. To browse the code, you can use the <a href="../doxydoc/index.html" target="_top"><span class="emphasis"><em>Bimap
  56. Complete Reference</em></span></a>, a doxygen-powered document targeted
  57. at developers.
  58. </p></td></tr>
  59. </table></div>
  60. <div class="section">
  61. <div class="titlepage"><div><div><h3 class="title">
  62. <a name="boost_bimap.rationale.general_design"></a><a class="link" href="rationale.html#boost_bimap.rationale.general_design" title="General Design">General Design</a>
  63. </h3></div></div></div>
  64. <p>
  65. The initial explanation includes few features. This section aims to describe
  66. the general design of the library and excludes details of those features
  67. that are of lesser importance; these features will be introduced later.
  68. </p>
  69. <p>
  70. The design of the library is divided into two parts. The first is the construction
  71. of a <code class="literal">relation</code> class. This will be the object stored and
  72. managed by the <code class="literal">multi_index_container</code> core. The idea is
  73. to make this class as easy as possible to use, while making it efficient
  74. in terms of memory and access time. This is a cornerstone in the design of
  75. <span class="bold"><strong>Boost.Bimap</strong></span> and, as you will see in this
  76. rationale, the rest of the design follows easily.
  77. </p>
  78. <p>
  79. The following interface is necessary for the <code class="literal">relation</code>
  80. class:
  81. </p>
  82. <pre class="programlisting"><span class="keyword">typedef</span> <span class="special">-</span><span class="identifier">unspecified</span><span class="special">-</span> <span class="identifier">TA</span><span class="special">;</span> <span class="keyword">typedef</span> <span class="special">-</span><span class="identifier">unspecified</span><span class="special">-</span> <span class="identifier">TB</span><span class="special">;</span>
  83. <span class="identifier">TA</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">ai</span><span class="special">;</span> <span class="identifier">TB</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">bi</span><span class="special">;</span>
  84. <span class="keyword">typedef</span> <span class="identifier">relation</span><span class="special">&lt;</span> <span class="identifier">TA</span><span class="special">,</span> <span class="identifier">TB</span> <span class="special">&gt;</span> <span class="identifier">rel</span><span class="special">;</span>
  85. <span class="identifier">STATIC_ASSERT</span><span class="special">(</span> <span class="identifier">is_same</span><span class="special">&lt;</span> <span class="identifier">rel</span><span class="special">::</span><span class="identifier">left_type</span> <span class="special">,</span> <span class="identifier">TA</span> <span class="special">&gt;::</span><span class="identifier">value</span> <span class="special">);</span>
  86. <span class="identifier">STATIC_ASSERT</span><span class="special">(</span> <span class="identifier">is_same</span><span class="special">&lt;</span> <span class="identifier">rel</span><span class="special">::</span><span class="identifier">right_type</span><span class="special">,</span> <span class="identifier">TB</span> <span class="special">&gt;::</span><span class="identifier">value</span> <span class="special">);</span>
  87. <span class="identifier">rel</span> <span class="identifier">r</span><span class="special">(</span><span class="identifier">ai</span><span class="special">,</span><span class="identifier">bi</span><span class="special">);</span>
  88. <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">left</span> <span class="special">==</span> <span class="identifier">ai</span> <span class="special">&amp;&amp;</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">right</span> <span class="special">==</span> <span class="identifier">bi</span> <span class="special">);</span>
  89. <span class="identifier">r</span><span class="special">.</span><span class="identifier">left</span> <span class="special">=</span> <span class="identifier">a</span><span class="special">;</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">right</span> <span class="special">=</span> <span class="identifier">b</span><span class="special">;</span>
  90. <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">left</span> <span class="special">==</span> <span class="identifier">a</span> <span class="special">&amp;&amp;</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">right</span> <span class="special">==</span> <span class="identifier">b</span> <span class="special">);</span>
  91. <span class="keyword">typedef</span> <span class="identifier">pair_type_by</span><span class="special">&lt;</span> <span class="identifier">member_at</span><span class="special">::</span><span class="identifier">left</span> <span class="special">,</span> <span class="identifier">rel</span> <span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">pba_type</span><span class="special">;</span>
  92. <span class="identifier">STATIC_ASSERT</span><span class="special">(</span> <span class="identifier">is_same</span><span class="special">&lt;</span> <span class="identifier">pba_type</span><span class="special">::</span><span class="identifier">first_type</span> <span class="special">,</span> <span class="identifier">TA</span> <span class="special">&gt;::</span><span class="identifier">value</span> <span class="special">);</span>
  93. <span class="identifier">STATIC_ASSERT</span><span class="special">(</span> <span class="identifier">is_same</span><span class="special">&lt;</span> <span class="identifier">pba_type</span><span class="special">::</span><span class="identifier">second_type</span><span class="special">,</span> <span class="identifier">TB</span> <span class="special">&gt;::</span><span class="identifier">value</span> <span class="special">);</span>
  94. <span class="keyword">typedef</span> <span class="identifier">pair_type_by</span><span class="special">&lt;</span> <span class="identifier">member_at</span><span class="special">::</span><span class="identifier">right</span><span class="special">,</span> <span class="identifier">rel</span> <span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">pbb_type</span><span class="special">;</span>
  95. <span class="identifier">STATIC_ASSERT</span><span class="special">(</span> <span class="identifier">is_same</span><span class="special">&lt;</span> <span class="identifier">pbb_type</span><span class="special">::</span><span class="identifier">first_type</span> <span class="special">,</span> <span class="identifier">TB</span> <span class="special">&gt;::</span><span class="identifier">value</span> <span class="special">);</span>
  96. <span class="identifier">STATIC_ASSERT</span><span class="special">(</span> <span class="identifier">is_same</span><span class="special">&lt;</span> <span class="identifier">pbb_type</span><span class="special">::</span><span class="identifier">second_type</span><span class="special">,</span> <span class="identifier">TA</span> <span class="special">&gt;::</span><span class="identifier">value</span> <span class="special">);</span>
  97. <span class="identifier">pba_type</span> <span class="identifier">pba</span> <span class="special">=</span> <span class="identifier">pair_by</span><span class="special">&lt;</span> <span class="identifier">member_at</span><span class="special">::</span><span class="identifier">left</span> <span class="special">&gt;(</span><span class="identifier">r</span><span class="special">);</span>
  98. <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">pba</span><span class="special">.</span><span class="identifier">first</span> <span class="special">==</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">left</span> <span class="special">&amp;&amp;</span> <span class="identifier">pba</span><span class="special">.</span><span class="identifier">second</span> <span class="special">==</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">right</span> <span class="special">);</span>
  99. <span class="identifier">pbb_type</span> <span class="identifier">pbb</span> <span class="special">=</span> <span class="identifier">pair_by</span><span class="special">&lt;</span> <span class="identifier">member_at</span><span class="special">::</span><span class="identifier">right</span> <span class="special">&gt;(</span><span class="identifier">r</span><span class="special">);</span>
  100. <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">pbb</span><span class="special">.</span><span class="identifier">first</span> <span class="special">==</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">right</span> <span class="special">&amp;&amp;</span> <span class="identifier">pbb</span><span class="special">.</span><span class="identifier">second</span> <span class="special">==</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">left</span> <span class="special">);</span>
  101. </pre>
  102. <p>
  103. <span class="inlinemediaobject"><img src="../images/bimap/relation.png" alt="relation"></span>
  104. </p>
  105. <p>
  106. Although this seems straightforward, as will be seen later, it is the most
  107. difficult code hack of the library. It is indeed very easy if we relax some
  108. of the efficiency constraints. For example, it is trivial if we allow a relation
  109. to have greater size than the the sum of those of its components. It is equally
  110. simple if access speed is not important. One of the first decisions made
  111. about <span class="bold"><strong>Boost.Bimap</strong></span> was, however, that, in
  112. order to be useful, it had to achieve zero overhead over the wrapped <span class="bold"><strong>Boost.MultiIndex</strong></span> container. Finally, there is another
  113. constraint that can be relaxed: conformance to C++ standards, but this is
  114. quite unacceptable. Let us now suppose that we have coded this class, and
  115. it conforms to what was required.
  116. </p>
  117. <p>
  118. The second part is based on this <code class="literal">relation</code> class. We can
  119. now view the data in any of three ways: <code class="computeroutput"><span class="identifier">pair</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">&gt;</span></code>,
  120. <code class="computeroutput"><span class="identifier">relation</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">&gt;</span></code> and <code class="computeroutput"><span class="identifier">pair</span><span class="special">&lt;</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">A</span><span class="special">&gt;</span></code>.
  121. Suppose that our bimap supports only one-to-one relations. (Other relation
  122. types are considered additional features in this design.) The proposed interface
  123. is very simple, and it is based heavily on the concepts of the STL. Given
  124. a <code class="computeroutput"><span class="identifier">bimap</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">&gt;</span> <span class="identifier">bm</span></code>:
  125. </p>
  126. <div class="orderedlist"><ol class="orderedlist" type="1">
  127. <li class="listitem">
  128. <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span></code> is signature-compatible with a
  129. <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">&gt;</span></code>
  130. </li>
  131. <li class="listitem">
  132. <code class="computeroutput"><span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span></code> is signature-compatible with
  133. a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">A</span><span class="special">&gt;</span></code>
  134. </li>
  135. <li class="listitem">
  136. <code class="computeroutput"><span class="identifier">bm</span></code> is signature-compatible
  137. with a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span><span class="special">&lt;</span><span class="identifier">relation</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">&gt;</span> <span class="special">&gt;</span></code>
  138. </li>
  139. </ol></div>
  140. <p>
  141. <span class="inlinemediaobject"><img src="../images/bimap/simple.bimap.png" alt="simple.bimap"></span>
  142. </p>
  143. <p>
  144. This interface is easily learned by users who have a STL background, as well
  145. as being simple and powerful. This is the general design.
  146. </p>
  147. <h5>
  148. <a name="boost_bimap.rationale.general_design.h0"></a>
  149. <span class="phrase"><a name="boost_bimap.rationale.general_design.relation_implementation"></a></span><a class="link" href="rationale.html#boost_bimap.rationale.general_design.relation_implementation">Relation
  150. Implementation</a>
  151. </h5>
  152. <p>
  153. This section explains the details of the actual <code class="literal">relation</code>
  154. class implementation.
  155. </p>
  156. <p>
  157. The first thing that we can imagine is the use of an <code class="literal">union</code>.
  158. Regrettably, the current C++ standard only allows unions of POD types. For
  159. the views, we can try a wrapper around a <code class="computeroutput"><span class="identifier">relation</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">&gt;</span></code> that
  160. has two references named first and second that bind to <code class="computeroutput"><span class="identifier">A</span></code>
  161. and <code class="computeroutput"><span class="identifier">B</span></code>, or to <code class="computeroutput"><span class="identifier">B</span></code> and <code class="computeroutput"><span class="identifier">A</span></code>.
  162. </p>
  163. <pre class="programlisting"><span class="identifier">relation</span><span class="special">&lt;</span><span class="identifier">TA</span><span class="special">,</span><span class="identifier">TB</span><span class="special">&gt;</span> <span class="identifier">r</span><span class="special">;</span>
  164. <span class="identifier">const_reference_pair</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">&gt;</span> <span class="identifier">pba</span><span class="special">(</span><span class="identifier">r</span><span class="special">);</span>
  165. <span class="identifier">const_reference_pair</span><span class="special">&lt;</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">A</span><span class="special">&gt;</span> <span class="identifier">pbb</span><span class="special">(</span><span class="identifier">r</span><span class="special">);</span>
  166. </pre>
  167. <p>
  168. It is not difficult to code the relation class using this, but two references
  169. are initialized at every access and using of <code class="computeroutput"><span class="identifier">pba</span><span class="special">.</span><span class="identifier">first</span></code>
  170. will be slower in most compilers than using <code class="computeroutput"><span class="identifier">r</span><span class="special">.</span><span class="identifier">left</span></code> directly
  171. . There is another hidden drawback of using this scheme: it is not iterator-friendly,
  172. since the map views iterators must be degraded to <span class="emphasis"><em>Read Write</em></span>
  173. instead of <span class="emphasis"><em>LValue</em></span>. This will be explained later.
  174. </p>
  175. <p>
  176. At first, this seems to be the best we can do with the current C++ standard.
  177. However there is a solution to this problem that does not conform very well
  178. to C++ standards but does achieve zero overhead in terms of access time and
  179. memory, and additionally allows the view iterators to be upgraded to <span class="emphasis"><em>LValue</em></span>
  180. again.
  181. </p>
  182. <p>
  183. In order to use this, the compiler must conform to a layout-compatibility
  184. clause that is not currently in the standard but is very natural. The additional
  185. clause imposes that if we have two classes:
  186. </p>
  187. <pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">class_a_b</span>
  188. <span class="special">{</span>
  189. <span class="identifier">Type1</span> <span class="identifier">name_a</span><span class="special">;</span>
  190. <span class="identifier">Type2</span> <span class="identifier">name_b</span><span class="special">;</span>
  191. <span class="special">};</span>
  192. <span class="keyword">struct</span> <span class="identifier">class_b_a</span>
  193. <span class="special">{</span>
  194. <span class="identifier">Type1</span> <span class="identifier">name_b</span><span class="special">;</span>
  195. <span class="identifier">Type2</span> <span class="identifier">name_a</span><span class="special">;</span>
  196. <span class="special">};</span>
  197. </pre>
  198. <p>
  199. then the storage layout of <code class="literal">class_a_b</code> is equal to the storage
  200. layout of <code class="literal">class_b_a</code>. If you are surprised to learn that
  201. this does not hold in a standards-compliant C++ compiler, welcome to the
  202. club. It is the natural way to implement it from the point of view of the
  203. compiler's vendor and is very useful for the developer. Maybe it will be
  204. included in the standard some day. Every current compiler conforms to this.
  205. </p>
  206. <p>
  207. If we are able to count on this, then we can implement an idiom called <code class="literal">mutant</code>.
  208. The idea is to provide a secure wrapper around <code class="literal">reinterpret_cast</code>.
  209. A class can declare that it can be viewed using different view classes that
  210. are storage-compatible with it. Then we use the free function <code class="literal">mutate&lt;view&gt;(mutant)</code>
  211. to get the view. The <code class="computeroutput"><span class="identifier">mutate</span></code>
  212. function checks at compile time that the requested view is declared in the
  213. mutant views list. We implement a class name <code class="computeroutput"><span class="identifier">structured_pair</span></code>
  214. that is signature-compatible with a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span></code>,
  215. while the storage layout is configured with a third template parameter. Two
  216. instances of this template class will provide the views of the relation.
  217. </p>
  218. <p>
  219. The thing is that if we want to be standards-compliant, we cannot use this
  220. approach. It is very annoying not to be able to use something that we know
  221. will work with every compiler and that is far better than alternatives. So
  222. -- and this is an important decision -- we have to find a way to use it and
  223. still make the library standards-compliant.
  224. </p>
  225. <p>
  226. The idea is very simple. We code both approaches: the const_reference_pair-based
  227. and the mutant-based, and use the mutant approach if the compiler is compliant
  228. with our new layout-compatible clause. If the compiler really messes things
  229. up, we degrade the performance of the bimap a little. The only drawback here
  230. is that, while the mutant approach allows to make <span class="emphasis"><em>LValue</em></span>
  231. iterators, we have to degrade them to <span class="emphasis"><em>Read Write</em></span> in
  232. both cases, because we require that the same code be compilable by any standards-compliant
  233. compiler.
  234. </p>
  235. <div class="note"><table border="0" summary="Note">
  236. <tr>
  237. <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
  238. <th align="left">Note</th>
  239. </tr>
  240. <tr><td align="left" valign="top"><p>
  241. Testing this approach in all the supported compilers indicated that the
  242. mutant idiom was always supported. The strictly compliant version was removed
  243. from the code because it was never used.
  244. </p></td></tr>
  245. </table></div>
  246. <h5>
  247. <a name="boost_bimap.rationale.general_design.h1"></a>
  248. <span class="phrase"><a name="boost_bimap.rationale.general_design.bimap_implementation"></a></span><a class="link" href="rationale.html#boost_bimap.rationale.general_design.bimap_implementation">Bimap
  249. Implementation</a>
  250. </h5>
  251. <p>
  252. The core of bimap will be obviously a <code class="computeroutput"><span class="identifier">multi_index_container</span></code>.
  253. The basic idea to tackle the implementation of the bimap class is to use
  254. <code class="literal">iterator_adaptor</code> to convert the iterators from Boost.MultiIndex
  255. to the <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span></code> and <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span></code> behaviour.
  256. The <code class="computeroutput"><span class="identifier">map_view</span></code> and the <code class="computeroutput"><span class="identifier">set_view</span></code> can be implemented directly using
  257. this new transformed iterators and a wrapper around each index of the core
  258. container. However, there is a hidden idiom here, that, once coded, will
  259. be very useful for other parts of this library and for Boost.MRU library.
  260. Following the ideas from <code class="computeroutput"><span class="identifier">iterator_adaptor</span></code>,
  261. Boost.Bimap views are implemented using a <code class="literal">container_adaptor</code>.
  262. There are several template classes (for example <code class="computeroutput"><span class="identifier">map_adaptor</span></code>
  263. and <code class="computeroutput"><span class="identifier">set_adaptor</span></code>) that take
  264. a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span></code> signature-conformant class and new
  265. iterators, and adapt the container so it now uses this iterators instead
  266. of the originals. For example, if you have a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">*&gt;</span></code>,
  267. you can build other container that behaves exactly as a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span></code> using
  268. <code class="computeroutput"><span class="identifier">set_adaptor</span></code> and <code class="literal">iterator_adaptor</code>.
  269. The combined use of this two tools is very powerful. A <code class="literal">container_adaptor</code>
  270. can take classes that do not fulfil all the requirements of the adapted container.
  271. The new container must define these missing functions.
  272. </p>
  273. </div>
  274. </div>
  275. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  276. <td align="left"></td>
  277. <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2012 Matias Capeletto<p>
  278. Distributed under the Boost Software License, Version 1.0. (See accompanying
  279. 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>)
  280. </p>
  281. </div></td>
  282. </tr></table>
  283. <hr>
  284. <div class="spirit-nav">
  285. <a accesskey="p" href="release_notes.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.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="rationale/additional_features.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
  286. </div>
  287. </body>
  288. </html>