Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/utility/MultiPassInputIterator.html @ 12

Last change on this file since 12 was 12, checked in by landauf, 18 years ago

added boost

File size: 3.5 KB
Line 
1<HTML>
2<!--
3  -- Copyright (c) Jeremy Siek 2000
4  --
5  -- Permission to use, copy, modify, distribute and sell this software
6  -- and its documentation for any purpose is hereby granted without fee,
7  -- provided that the above copyright notice appears in all copies and
8  -- that both that copyright notice and this permission notice appear
9  -- in supporting documentation.  Silicon Graphics makes no
10  -- representations about the suitability of this software for any
11  -- purpose.  It is provided "as is" without express or implied warranty.
12  -->
13<Head>
14<Title>MultiPassInputIterator</Title>
15<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b" 
16        ALINK="#ff0000"> 
17<IMG SRC="../../boost.png" 
18     ALT="C++ Boost" width="277" height="86"> 
19
20<BR Clear>
21
22<H2>
23<A NAME="concept:MultiPassInputIterator"></A>
24Multi-Pass Input Iterator
25</H2>
26
27This concept is a refinement of <a
28href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
29adding the requirements that the iterator can be used to make multiple
30passes through a range, and that if <TT>it1 == it2</TT> and
31<TT>it1</TT> is dereferenceable then <TT>++it1 == ++it2</TT>. The
32Multi-Pass Input Iterator is very similar to the <a
33href="http://www.sgi.com/tech/stl/ForwardIterator.html">Forward Iterator</a>. The
34only difference is that a <a
35href="http://www.sgi.com/tech/stl/ForwardIterator.html">Forward Iterator</a>
36requires the <TT>reference</TT> type to be <TT>value_type&amp;</TT>, whereas
37MultiPassInputIterator is like <a
38href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>
39in that the <TT>reference</TT> type merely has to be convertible to
40<TT>value_type</TT>.
41
42
43<h3>Design Notes</h3>
44
45comments by Valentin Bonnard:
46
47<p> I think that introducing Multi-Pass Input Iterator isn't the right
48solution. Do you also want to define Multi-Pass Bidirectionnal Iterator
49and Multi-Pass Random Access Iterator ? I don't, definitly. It only
50confuses the issue. The problem lies into the existing hierarchy of
51iterators, which mixes movabillity, modifiabillity and lvalue-ness,
52and these are clearly independant.
53
54<p> The terms Forward, Bidirectionnal and Random Access are about
55movabillity and shouldn't be used to mean anything else.  In a
56completly orthogonal way, iterators can be immutable, mutable, or
57neither.  Lvalueness of iterators is also orthogonal with
58immutabillity.  With these clean concepts, your Multi-Pass Input Iterator
59is just called a Forward Iterator.
60
61<p>               
62Other translations are:<br>
63std::Forward Iterator -> ForwardIterator & Lvalue Iterator<br>
64std::Bidirectionnal Iterator -> Bidirectionnal Iterator & Lvalue Iterator<br>
65std::Random Access Iterator -> Random Access Iterator & Lvalue Iterator<br>
66
67<p>
68Note that in practice the only operation not allowed on my
69Forward Iterator which is allowed on std::Forward Iterator is
70<tt>&*it</tt>. I think that <tt>&*</tt> is rarely needed in generic code.
71
72<p>
73reply by Jeremy Siek:
74
75<p>
76The above analysis by Valentin is right on. Of course, there is
77the problem with backward compatibility. The current STL implementations
78are based on the old definition of Forward Iterator. The right course
79of action is to get Forward Iterator, etc. changed in the C++ standard.
80Once that is done we can drop Multi-Pass Input Iterator.
81
82
83<br>
84<HR>
85<TABLE>
86<TR valign=top>
87<TD nowrap>Copyright &copy 2000</TD><TD>
88<a HREF="../../people/jeremy_siek.htm">Jeremy Siek</a>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
89</TD></TR></TABLE>
90
91</BODY>
92</HTML> 
Note: See TracBrowser for help on using the repository browser.