• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Iterator Concepts</title>
5<link rel="stylesheet" href="../../../../../doc/src/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.Iterator">
8<link rel="up" href="../index.html" title="Chapter 1. Boost.Iterator">
9<link rel="prev" href="../index.html" title="Chapter 1. Boost.Iterator">
10<link rel="next" href="concepts/traversal.html" title="Traversal">
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="../index.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="concepts/traversal.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="iterator.concepts"></a><a class="link" href="concepts.html" title="Iterator Concepts">Iterator Concepts</a>
28</h2></div></div></div>
29<div class="toc"><dl class="toc">
30<dt><span class="section"><a href="concepts.html#iterator.concepts.access">Access</a></span></dt>
31<dd><dl>
32<dt><span class="section"><a href="concepts.html#iterator.concepts.access.readable">Readable Iterator
33        Concept</a></span></dt>
34<dt><span class="section"><a href="concepts.html#iterator.concepts.access.writable">Writable Iterator
35        Concept</a></span></dt>
36<dt><span class="section"><a href="concepts.html#iterator.concepts.access.swappable">Swappable Iterator
37        Concept</a></span></dt>
38<dt><span class="section"><a href="concepts.html#iterator.concepts.access.lvalue">Lvalue Iterator Concept</a></span></dt>
39</dl></dd>
40<dt><span class="section"><a href="concepts/traversal.html">Traversal</a></span></dt>
41<dd><dl>
42<dt><span class="section"><a href="concepts/traversal.html#iterator.concepts.traversal.incrementable">Incrementable
43        Iterator Concept</a></span></dt>
44<dt><span class="section"><a href="concepts/traversal.html#iterator.concepts.traversal.single_pass">Single Pass
45        Iterator Concept</a></span></dt>
46<dt><span class="section"><a href="concepts/traversal.html#iterator.concepts.traversal.forward">Forward Traversal
47        Concept</a></span></dt>
48<dt><span class="section"><a href="concepts/traversal.html#iterator.concepts.traversal.bidirectional">Bidirectional
49        Traversal Concept</a></span></dt>
50<dt><span class="section"><a href="concepts/traversal.html#iterator.concepts.traversal.random_access">Random Access
51        Traversal Concept</a></span></dt>
52</dl></dd>
53</dl></div>
54<div class="section">
55<div class="titlepage"><div><div><h3 class="title">
56<a name="iterator.concepts.access"></a><a class="link" href="concepts.html#iterator.concepts.access" title="Access">Access</a>
57</h3></div></div></div>
58<div class="toc"><dl class="toc">
59<dt><span class="section"><a href="concepts.html#iterator.concepts.access.readable">Readable Iterator
60        Concept</a></span></dt>
61<dt><span class="section"><a href="concepts.html#iterator.concepts.access.writable">Writable Iterator
62        Concept</a></span></dt>
63<dt><span class="section"><a href="concepts.html#iterator.concepts.access.swappable">Swappable Iterator
64        Concept</a></span></dt>
65<dt><span class="section"><a href="concepts.html#iterator.concepts.access.lvalue">Lvalue Iterator Concept</a></span></dt>
66</dl></div>
67<div class="section">
68<div class="titlepage"><div><div><h4 class="title">
69<a name="iterator.concepts.access.readable"></a><a class="link" href="concepts.html#iterator.concepts.access.readable" title="Readable Iterator Concept">Readable Iterator
70        Concept</a>
71</h4></div></div></div>
72<p>
73          A class or built-in type <code class="computeroutput"><span class="identifier">X</span></code>
74          models the <span class="bold"><strong>Readable Iterator</strong></span> concept for
75          value type <code class="computeroutput"><span class="identifier">T</span></code> if, in addition
76          to <code class="computeroutput"><span class="identifier">X</span></code> being Assignable and
77          Copy Constructible, the following expressions are valid and respect the
78          stated semantics. <code class="computeroutput"><span class="identifier">U</span></code> is
79          the type of any specified member of type <code class="computeroutput"><span class="identifier">T</span></code>.
80        </p>
81<div class="table">
82<a name="iterator.concepts.access.readable.readable_iterator_requirements_i"></a><p class="title"><b>Table 1.1. Readable Iterator Requirements (in addition to Assignable and Copy
83          Constructible)</b></p>
84<div class="table-contents"><table class="table" summary="Readable Iterator Requirements (in addition to Assignable and Copy
85          Constructible)">
86<colgroup>
87<col>
88<col>
89<col>
90</colgroup>
91<thead><tr>
92<th>
93                  <p>
94                    Expression
95                  </p>
96                </th>
97<th>
98                  <p>
99                    Return Type
100                  </p>
101                </th>
102<th>
103                  <p>
104                    Note/Precondition
105                  </p>
106                </th>
107</tr></thead>
108<tbody>
109<tr>
110<td>
111                  <p>
112                    <code class="computeroutput"><span class="identifier">iterator_traits</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">value_type</span></code>
113                  </p>
114                </td>
115<td>
116                  <p>
117                    <code class="computeroutput"><span class="identifier">T</span></code>
118                  </p>
119                </td>
120<td>
121                  <p>
122                    Any non-reference, non cv-qualified type
123                  </p>
124                </td>
125</tr>
126<tr>
127<td>
128                  <p>
129                    <code class="computeroutput"><span class="special">*</span><span class="identifier">a</span></code>
130                  </p>
131                </td>
132<td>
133                  <p>
134                    Convertible to <code class="computeroutput"><span class="identifier">T</span></code>
135                  </p>
136                </td>
137<td>
138                  <p>
139                    pre: <code class="computeroutput"><span class="identifier">a</span></code> is dereferenceable.
140                    If <code class="computeroutput"><span class="identifier">a</span> <span class="special">==</span>
141                    <span class="identifier">b</span></code> then <code class="computeroutput"><span class="special">*</span><span class="identifier">a</span></code>
142                    is equivalent to <code class="computeroutput"><span class="special">*</span><span class="identifier">b</span></code>.
143                  </p>
144                </td>
145</tr>
146<tr>
147<td>
148                  <p>
149                    <code class="computeroutput"><span class="identifier">a</span><span class="special">-&gt;</span><span class="identifier">m</span></code>
150                  </p>
151                </td>
152<td>
153                  <p>
154                    <code class="computeroutput"><span class="identifier">U</span><span class="special">&amp;</span></code>
155                  </p>
156                </td>
157<td>
158                  <p>
159                    pre: <code class="computeroutput"><span class="special">(*</span><span class="identifier">a</span><span class="special">).</span><span class="identifier">m</span></code>
160                    is well-defined. Equivalent to <code class="computeroutput"><span class="special">(*</span><span class="identifier">a</span><span class="special">).</span><span class="identifier">m</span></code>.
161                  </p>
162                </td>
163</tr>
164</tbody>
165</table></div>
166</div>
167<br class="table-break">
168</div>
169<div class="section">
170<div class="titlepage"><div><div><h4 class="title">
171<a name="iterator.concepts.access.writable"></a><a class="link" href="concepts.html#iterator.concepts.access.writable" title="Writable Iterator Concept">Writable Iterator
172        Concept</a>
173</h4></div></div></div>
174<p>
175          A class or built-in type <code class="computeroutput"><span class="identifier">X</span></code>
176          models the <span class="bold"><strong>Writable Iterator</strong></span> concept if,
177          in addition to <code class="computeroutput"><span class="identifier">X</span></code> being
178          Copy Constructible, the following expressions are valid and respect the
179          stated semantics. Writable Iterators have an associated <span class="bold"><strong>set
180          of value types</strong></span>.
181        </p>
182<div class="table">
183<a name="iterator.concepts.access.writable.writable_iterator_requirements_i"></a><p class="title"><b>Table 1.2. Writable Iterator Requirements (in addition to Copy Constructible)</b></p>
184<div class="table-contents"><table class="table" summary="Writable Iterator Requirements (in addition to Copy Constructible)">
185<colgroup>
186<col>
187<col>
188<col>
189</colgroup>
190<thead><tr>
191<th>
192                  <p>
193                    Expression
194                  </p>
195                </th>
196<th>
197                  <p>
198                    Return Type
199                  </p>
200                </th>
201<th>
202                  <p>
203                    Precondition
204                  </p>
205                </th>
206</tr></thead>
207<tbody><tr>
208<td>
209                  <p>
210                    <code class="computeroutput"><span class="special">*</span><span class="identifier">a</span>
211                    <span class="special">=</span> <span class="identifier">o</span></code>
212                  </p>
213                </td>
214<td>
215                </td>
216<td>
217                  <p>
218                    pre: The type of <code class="computeroutput"><span class="identifier">o</span></code>
219                    is in the set of value types of <code class="computeroutput"><span class="identifier">X</span></code>
220                  </p>
221                </td>
222</tr></tbody>
223</table></div>
224</div>
225<br class="table-break">
226</div>
227<div class="section">
228<div class="titlepage"><div><div><h4 class="title">
229<a name="iterator.concepts.access.swappable"></a><a class="link" href="concepts.html#iterator.concepts.access.swappable" title="Swappable Iterator Concept">Swappable Iterator
230        Concept</a>
231</h4></div></div></div>
232<p>
233          A class or built-in type <code class="computeroutput"><span class="identifier">X</span></code>
234          models the <span class="bold"><strong>Swappable Iterator</strong></span> concept
235          if, in addition to <code class="computeroutput"><span class="identifier">X</span></code> being
236          Copy Constructible, the following expressions are valid and respect the
237          stated semantics.
238        </p>
239<div class="table">
240<a name="iterator.concepts.access.swappable.swappable_iterator_requirements_"></a><p class="title"><b>Table 1.3. Swappable Iterator Requirements (in addition to Copy Constructible)</b></p>
241<div class="table-contents"><table class="table" summary="Swappable Iterator Requirements (in addition to Copy Constructible)">
242<colgroup>
243<col>
244<col>
245<col>
246</colgroup>
247<thead><tr>
248<th>
249                  <p>
250                    Expression
251                  </p>
252                </th>
253<th>
254                  <p>
255                    Return Type
256                  </p>
257                </th>
258<th>
259                  <p>
260                    Postcondition
261                  </p>
262                </th>
263</tr></thead>
264<tbody><tr>
265<td>
266                  <p>
267                    <code class="computeroutput"><span class="identifier">iter_swap</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span>
268                    <span class="identifier">b</span><span class="special">)</span></code>
269                  </p>
270                </td>
271<td>
272                  <p>
273                    <code class="computeroutput"><span class="keyword">void</span></code>
274                  </p>
275                </td>
276<td>
277                  <p>
278                    the pointed to values are exchanged
279                  </p>
280                </td>
281</tr></tbody>
282</table></div>
283</div>
284<br class="table-break"><div class="blurb">
285<div class="titlepage"><div><div><p class="title"><b></b></p></div></div></div>
286<p>
287          <span class="bold"><strong>Note:</strong></span> An iterator that is a model of the
288          <span class="bold"><strong>Readable</strong></span> and <span class="bold"><strong>Writable
289          Iterator</strong></span> concepts is also a model of <span class="bold"><strong>Swappable
290          Iterator</strong></span>. <span class="bold"><strong>--end note</strong></span>
291        </p>
292</div>
293</div>
294<div class="section">
295<div class="titlepage"><div><div><h4 class="title">
296<a name="iterator.concepts.access.lvalue"></a><a class="link" href="concepts.html#iterator.concepts.access.lvalue" title="Lvalue Iterator Concept">Lvalue Iterator Concept</a>
297</h4></div></div></div>
298<p>
299          The <span class="bold"><strong>Lvalue Iterator</strong></span> concept adds the requirement
300          that the return type of <code class="computeroutput"><span class="keyword">operator</span><span class="special">*</span></code> type be a reference to the value type
301          of the iterator.
302        </p>
303<div class="table">
304<a name="iterator.concepts.access.lvalue.lvalue_iterator_requirements"></a><p class="title"><b>Table 1.4. Lvalue Iterator Requirements</b></p>
305<div class="table-contents"><table class="table" summary="Lvalue Iterator Requirements">
306<colgroup>
307<col>
308<col>
309<col>
310</colgroup>
311<thead><tr>
312<th>
313                  <p>
314                    Expression
315                  </p>
316                </th>
317<th>
318                  <p>
319                    Return Type
320                  </p>
321                </th>
322<th>
323                  <p>
324                    Note/Assertion
325                  </p>
326                </th>
327</tr></thead>
328<tbody><tr>
329<td>
330                  <p>
331                    <code class="computeroutput"><span class="special">*</span><span class="identifier">a</span></code>
332                  </p>
333                </td>
334<td>
335                  <p>
336                    <code class="computeroutput"><span class="identifier">T</span><span class="special">&amp;</span></code>
337                  </p>
338                </td>
339<td>
340                  <p>
341                    <code class="computeroutput"><span class="identifier">T</span></code> is <span class="bold"><strong>cv</strong></span> <code class="computeroutput"><span class="identifier">iterator_traits</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">value_type</span></code>
342                    where <span class="bold"><strong>cv</strong></span> is an optional cv-qualification.
343                    pre: <code class="computeroutput"><span class="identifier">a</span></code> is dereferenceable.
344                    If <code class="computeroutput"><span class="identifier">a</span> <span class="special">==</span>
345                    <span class="identifier">b</span></code> then <code class="computeroutput"><span class="special">*</span><span class="identifier">a</span></code>
346                    is equivalent to <code class="computeroutput"><span class="special">*</span><span class="identifier">b</span></code>.
347                  </p>
348                </td>
349</tr></tbody>
350</table></div>
351</div>
352<br class="table-break">
353</div>
354</div>
355</div>
356<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
357<td align="left"></td>
358<td align="right"><div class="copyright-footer">Copyright © 2003, 2005 David Abrahams Jeremy Siek Thomas
359      Witt<p>
360        Distributed under the Boost Software License, Version 1.0. (See accompanying
361        file LICENSE_1_0.txt or copy at &lt;ulink url="http://www.boost.org/LICENSE_1_0.txt"&gt;
362        http://www.boost.org/LICENSE_1_0.txt &lt;/ulink&gt;)
363      </p>
364</div></td>
365</tr></table>
366<hr>
367<div class="spirit-nav">
368<a accesskey="p" href="../index.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="concepts/traversal.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
369</div>
370</body>
371</html>
372