]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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@boost-consulting.com">dave@boost-consulting.com</a>, <a class="reference external" href="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</a>, <a class="last reference external" href="mailto:witt@styleadvisor.com">witt@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 | ||
71 | typedef /*implementation defined*/ readable_iterator_t; | |
72 | typedef /*implementation defined*/ writable_iterator_t; | |
73 | typedef /*implementation defined*/ readable_writable_iterator_t; | |
74 | typedef /*implementation defined*/ readable_lvalue_iterator_t; | |
75 | typedef /*implementation defined*/ writable_lvalue_iterator_t; | |
76 | ||
77 | } | |
78 | ||
79 | template < | |
80 | class Value | |
81 | , class AccessCategory | |
82 | , class TraversalCategory | |
83 | > | |
84 | class iterator_archetype | |
85 | { | |
86 | typedef /* see below */ value_type; | |
87 | typedef /* see below */ reference; | |
88 | typedef /* see below */ pointer; | |
89 | typedef /* see below */ difference_type; | |
90 | typedef /* see below */ iterator_category; | |
91 | }; | |
92 | </pre> | |
93 | </div> | |
94 | <div class="section" id="access-category-tags"> | |
95 | <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> | |
96 | <p>The access category types provided correspond to the following | |
97 | standard iterator access concept combinations:</p> | |
98 | <pre class="literal-block"> | |
99 | readable_iterator_t := | |
100 | ||
101 | Readable Iterator | |
102 | ||
103 | writable_iterator_t := | |
104 | ||
105 | Writeable Iterator | |
106 | ||
107 | readable_writable_iterator_t := | |
108 | ||
109 | Readable Iterator & Writeable Iterator & Swappable Iterator | |
110 | ||
111 | readable_lvalue_iterator_t := | |
112 | ||
113 | Readable Iterator & Lvalue Iterator | |
114 | ||
115 | writeable_lvalue_iterator_t := | |
116 | ||
117 | Readable Iterator & Writeable Iterator & Swappable Iterator & Lvalue Iterator | |
118 | </pre> | |
119 | </div> | |
120 | <div class="section" id="iterator-archetype-requirements"> | |
121 | <h2><a class="toc-backref" href="#id4"><tt class="docutils literal"><span class="pre">iterator_archetype</span></tt> Requirements</a></h2> | |
122 | <p>The <tt class="docutils literal"><span class="pre">AccessCategory</span></tt> argument must be one of the predefined access | |
123 | category tags. The <tt class="docutils literal"><span class="pre">TraversalCategory</span></tt> must be one of the standard | |
124 | traversal tags. The <tt class="docutils literal"><span class="pre">Value</span></tt> type must satisfy the requirements of | |
125 | the iterator concept specified by <tt class="docutils literal"><span class="pre">AccessCategory</span></tt> and | |
126 | <tt class="docutils literal"><span class="pre">TraversalCategory</span></tt> as implied by the nested traits types.</p> | |
127 | </div> | |
128 | <div class="section" id="iterator-archetype-models"> | |
129 | <h2><a class="toc-backref" href="#id5"><tt class="docutils literal"><span class="pre">iterator_archetype</span></tt> Models</a></h2> | |
130 | <p><tt class="docutils literal"><span class="pre">iterator_archetype</span></tt> models the iterator concepts specified by the | |
131 | <tt class="docutils literal"><span class="pre">AccessCategory</span></tt> and <tt class="docutils literal"><span class="pre">TraversalCategory</span></tt> | |
132 | arguments. <tt class="docutils literal"><span class="pre">iterator_archetype</span></tt> does not model any other access | |
133 | concepts or any more derived traversal concepts.</p> | |
134 | </div> | |
135 | <div class="section" id="traits"> | |
136 | <h2><a class="toc-backref" href="#id6"><tt class="docutils literal"><span class="pre">Traits</span></tt></a></h2> | |
137 | <p>The nested trait types are defined as follows:</p> | |
138 | <pre class="literal-block"> | |
139 | if (AccessCategory == readable_iterator_t) | |
140 | ||
141 | value_type = Value | |
142 | reference = Value | |
143 | pointer = Value* | |
144 | ||
145 | else if (AccessCategory == writable_iterator_t) | |
146 | ||
147 | value_type = void | |
148 | reference = void | |
149 | pointer = void | |
150 | ||
151 | else if (AccessCategory == readable_writable_iterator_t) | |
152 | ||
153 | value_type = Value | |
154 | ||
155 | reference := | |
156 | ||
157 | A type X that is convertible to Value for which the following | |
158 | expression is valid. Given an object x of type X and v of type | |
159 | Value. | |
160 | ||
161 | x = v | |
162 | ||
163 | pointer = Value* | |
164 | ||
165 | else if (AccessCategory == readable_lvalue_iterator_t) | |
166 | ||
167 | value_type = Value | |
168 | reference = Value const& | |
169 | pointer = Value const* | |
170 | ||
171 | else if (AccessCategory == writable_lvalue_iterator_t) | |
172 | ||
173 | value_type = Value | |
174 | reference = Value& | |
175 | pointer = Value* | |
176 | ||
177 | if ( TraversalCategory is convertible to forward_traversal_tag ) | |
178 | ||
179 | difference_type := ptrdiff_t | |
180 | ||
181 | else | |
182 | ||
183 | difference_type := unspecified type | |
184 | ||
185 | ||
186 | iterator_category := | |
187 | ||
188 | A type X satisfying the following two constraints: | |
189 | ||
190 | 1. X is convertible to X1, and not to any more-derived | |
191 | type, where X1 is defined by: | |
192 | ||
193 | if (reference is a reference type | |
194 | && TraversalCategory is convertible to forward_traversal_tag) | |
195 | { | |
196 | if (TraversalCategory is convertible to random_access_traversal_tag) | |
197 | X1 = random_access_iterator_tag | |
198 | else if (TraversalCategory is convertible to bidirectional_traversal_tag) | |
199 | X1 = bidirectional_iterator_tag | |
200 | else | |
201 | X1 = forward_iterator_tag | |
202 | } | |
203 | else | |
204 | { | |
205 | if (TraversalCategory is convertible to single_pass_traversal_tag | |
206 | && reference != void) | |
207 | X1 = input_iterator_tag | |
208 | else | |
209 | X1 = output_iterator_tag | |
210 | } | |
211 | ||
212 | 2. X is convertible to TraversalCategory | |
213 | </pre> | |
214 | </div> | |
215 | </div> | |
216 | </div> | |
217 | <div class="footer"> | |
218 | <hr class="footer" /> | |
219 | <a class="reference external" href="iterator_archetypes.rst">View document source</a>. | |
220 | 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. | |
221 | ||
222 | </div> | |
223 | </body> | |
224 | </html> |