iterator_archetypes.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
  7. <title>Iterator Archetype</title>
  8. <meta name="author" content="David Abrahams, Jeremy Siek, Thomas Witt" />
  9. <meta name="organization" content="Boost Consulting, Indiana University Open Systems Lab, Zephyr Associates, Inc." />
  10. <meta name="date" content="2006-09-11" />
  11. <meta name="copyright" content="Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2004." />
  12. <link rel="stylesheet" href="../../../rst.css" type="text/css" />
  13. </head>
  14. <body>
  15. <div class="document" id="iterator-archetype">
  16. <h1 class="title">Iterator Archetype</h1>
  17. <table class="docinfo" frame="void" rules="none">
  18. <col class="docinfo-name" />
  19. <col class="docinfo-content" />
  20. <tbody valign="top">
  21. <tr><th class="docinfo-name">Author:</th>
  22. <td>David Abrahams, Jeremy Siek, Thomas Witt</td></tr>
  23. <tr><th class="docinfo-name">Contact:</th>
  24. <td><a class="first reference external" href="mailto:dave&#64;boost-consulting.com">dave&#64;boost-consulting.com</a>, <a class="reference external" href="mailto:jsiek&#64;osl.iu.edu">jsiek&#64;osl.iu.edu</a>, <a class="last reference external" href="mailto:witt&#64;styleadvisor.com">witt&#64;styleadvisor.com</a></td></tr>
  25. <tr><th class="docinfo-name">Organization:</th>
  26. <td><a class="first reference external" href="http://www.boost-consulting.com">Boost Consulting</a>, Indiana University <a class="reference external" href="http://www.osl.iu.edu">Open Systems
  27. Lab</a>, <a class="last reference external" href="http://www.styleadvisor.com">Zephyr Associates, Inc.</a></td></tr>
  28. <tr><th class="docinfo-name">Date:</th>
  29. <td>2006-09-11</td></tr>
  30. <tr><th class="docinfo-name">Copyright:</th>
  31. <td>Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2004.</td></tr>
  32. </tbody>
  33. </table>
  34. <!-- Distributed under the Boost -->
  35. <!-- Software License, Version 1.0. (See accompanying -->
  36. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  37. <table class="docutils field-list" frame="void" rules="none">
  38. <col class="field-name" />
  39. <col class="field-body" />
  40. <tbody valign="top">
  41. <tr class="field"><th class="field-name">abstract:</th><td class="field-body">The <tt class="docutils literal"><span class="pre">iterator_archetype</span></tt> class constructs a minimal implementation of
  42. one of the iterator access concepts and one of the iterator traversal concepts.
  43. This is used for doing a compile-time check to see if a the type requirements
  44. of a template are really enough to cover the implementation of the template.
  45. For further information see the documentation for the <a class="reference external" href="../../concept_check/index.html"><tt class="docutils literal"><span class="pre">boost::concept_check</span></tt></a> library.</td>
  46. </tr>
  47. </tbody>
  48. </table>
  49. <div class="contents topic" id="table-of-contents">
  50. <p class="topic-title first">Table of Contents</p>
  51. <ul class="simple">
  52. <li><a class="reference internal" href="#reference" id="id1">Reference</a><ul>
  53. <li><a class="reference internal" href="#iterator-archetype-synopsis" id="id2"><tt class="docutils literal"><span class="pre">iterator_archetype</span></tt> Synopsis</a></li>
  54. <li><a class="reference internal" href="#access-category-tags" id="id3"><tt class="docutils literal"><span class="pre">Access</span> <span class="pre">Category</span> <span class="pre">Tags</span></tt></a></li>
  55. <li><a class="reference internal" href="#iterator-archetype-requirements" id="id4"><tt class="docutils literal"><span class="pre">iterator_archetype</span></tt> Requirements</a></li>
  56. <li><a class="reference internal" href="#iterator-archetype-models" id="id5"><tt class="docutils literal"><span class="pre">iterator_archetype</span></tt> Models</a></li>
  57. <li><a class="reference internal" href="#traits" id="id6"><tt class="docutils literal"><span class="pre">Traits</span></tt></a></li>
  58. </ul>
  59. </li>
  60. </ul>
  61. </div>
  62. <div class="section" id="reference">
  63. <h1><a class="toc-backref" href="#id1">Reference</a></h1>
  64. <div class="section" id="iterator-archetype-synopsis">
  65. <h2><a class="toc-backref" href="#id2"><tt class="docutils literal"><span class="pre">iterator_archetype</span></tt> Synopsis</a></h2>
  66. <pre class="literal-block">
  67. namespace iterator_archetypes
  68. {
  69. // Access categories
  70. typedef /*implementation defined*/ readable_iterator_t;
  71. typedef /*implementation defined*/ writable_iterator_t;
  72. typedef /*implementation defined*/ readable_writable_iterator_t;
  73. typedef /*implementation defined*/ readable_lvalue_iterator_t;
  74. typedef /*implementation defined*/ writable_lvalue_iterator_t;
  75. }
  76. template &lt;
  77. class Value
  78. , class AccessCategory
  79. , class TraversalCategory
  80. &gt;
  81. class iterator_archetype
  82. {
  83. typedef /* see below */ value_type;
  84. typedef /* see below */ reference;
  85. typedef /* see below */ pointer;
  86. typedef /* see below */ difference_type;
  87. typedef /* see below */ iterator_category;
  88. };
  89. </pre>
  90. </div>
  91. <div class="section" id="access-category-tags">
  92. <h2><a class="toc-backref" href="#id3"><tt class="docutils literal"><span class="pre">Access</span> <span class="pre">Category</span> <span class="pre">Tags</span></tt></a></h2>
  93. <p>The access category types provided correspond to the following
  94. standard iterator access concept combinations:</p>
  95. <pre class="literal-block">
  96. readable_iterator_t :=
  97. Readable Iterator
  98. writable_iterator_t :=
  99. Writeable Iterator
  100. readable_writable_iterator_t :=
  101. Readable Iterator &amp; Writeable Iterator &amp; Swappable Iterator
  102. readable_lvalue_iterator_t :=
  103. Readable Iterator &amp; Lvalue Iterator
  104. writeable_lvalue_iterator_t :=
  105. Readable Iterator &amp; Writeable Iterator &amp; Swappable Iterator &amp; Lvalue Iterator
  106. </pre>
  107. </div>
  108. <div class="section" id="iterator-archetype-requirements">
  109. <h2><a class="toc-backref" href="#id4"><tt class="docutils literal"><span class="pre">iterator_archetype</span></tt> Requirements</a></h2>
  110. <p>The <tt class="docutils literal"><span class="pre">AccessCategory</span></tt> argument must be one of the predefined access
  111. category tags. The <tt class="docutils literal"><span class="pre">TraversalCategory</span></tt> must be one of the standard
  112. traversal tags. The <tt class="docutils literal"><span class="pre">Value</span></tt> type must satisfy the requirements of
  113. the iterator concept specified by <tt class="docutils literal"><span class="pre">AccessCategory</span></tt> and
  114. <tt class="docutils literal"><span class="pre">TraversalCategory</span></tt> as implied by the nested traits types.</p>
  115. </div>
  116. <div class="section" id="iterator-archetype-models">
  117. <h2><a class="toc-backref" href="#id5"><tt class="docutils literal"><span class="pre">iterator_archetype</span></tt> Models</a></h2>
  118. <p><tt class="docutils literal"><span class="pre">iterator_archetype</span></tt> models the iterator concepts specified by the
  119. <tt class="docutils literal"><span class="pre">AccessCategory</span></tt> and <tt class="docutils literal"><span class="pre">TraversalCategory</span></tt>
  120. arguments. <tt class="docutils literal"><span class="pre">iterator_archetype</span></tt> does not model any other access
  121. concepts or any more derived traversal concepts.</p>
  122. </div>
  123. <div class="section" id="traits">
  124. <h2><a class="toc-backref" href="#id6"><tt class="docutils literal"><span class="pre">Traits</span></tt></a></h2>
  125. <p>The nested trait types are defined as follows:</p>
  126. <pre class="literal-block">
  127. if (AccessCategory == readable_iterator_t)
  128. value_type = Value
  129. reference = Value
  130. pointer = Value*
  131. else if (AccessCategory == writable_iterator_t)
  132. value_type = void
  133. reference = void
  134. pointer = void
  135. else if (AccessCategory == readable_writable_iterator_t)
  136. value_type = Value
  137. reference :=
  138. A type X that is convertible to Value for which the following
  139. expression is valid. Given an object x of type X and v of type
  140. Value.
  141. x = v
  142. pointer = Value*
  143. else if (AccessCategory == readable_lvalue_iterator_t)
  144. value_type = Value
  145. reference = Value const&amp;
  146. pointer = Value const*
  147. else if (AccessCategory == writable_lvalue_iterator_t)
  148. value_type = Value
  149. reference = Value&amp;
  150. pointer = Value*
  151. if ( TraversalCategory is convertible to forward_traversal_tag )
  152. difference_type := ptrdiff_t
  153. else
  154. difference_type := unspecified type
  155. iterator_category :=
  156. A type X satisfying the following two constraints:
  157. 1. X is convertible to X1, and not to any more-derived
  158. type, where X1 is defined by:
  159. if (reference is a reference type
  160. &amp;&amp; TraversalCategory is convertible to forward_traversal_tag)
  161. {
  162. if (TraversalCategory is convertible to random_access_traversal_tag)
  163. X1 = random_access_iterator_tag
  164. else if (TraversalCategory is convertible to bidirectional_traversal_tag)
  165. X1 = bidirectional_iterator_tag
  166. else
  167. X1 = forward_iterator_tag
  168. }
  169. else
  170. {
  171. if (TraversalCategory is convertible to single_pass_traversal_tag
  172. &amp;&amp; reference != void)
  173. X1 = input_iterator_tag
  174. else
  175. X1 = output_iterator_tag
  176. }
  177. 2. X is convertible to TraversalCategory
  178. </pre>
  179. </div>
  180. </div>
  181. </div>
  182. <div class="footer">
  183. <hr class="footer" />
  184. <a class="reference external" href="iterator_archetypes.rst">View document source</a>.
  185. Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
  186. </div>
  187. </body>
  188. </html>