1 | <HTML>
|
---|
2 | <!--
|
---|
3 | Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
---|
4 |
|
---|
5 | Distributed under the Boost Software License, Version 1.0.
|
---|
6 | (See accompanying file LICENSE_1_0.txt or copy at
|
---|
7 | http://www.boost.org/LICENSE_1_0.txt)
|
---|
8 | -->
|
---|
9 | <Head>
|
---|
10 | <Title>Iterator Property Map Adaptor</Title>
|
---|
11 | <BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
---|
12 | ALINK="#ff0000">
|
---|
13 | <IMG SRC="../../../boost.png"
|
---|
14 | ALT="C++ Boost" width="277" height="86">
|
---|
15 |
|
---|
16 | <BR Clear>
|
---|
17 |
|
---|
18 |
|
---|
19 | <H2><A NAME="sec:iterator-property-map"></A>
|
---|
20 | </h2>
|
---|
21 | <PRE>
|
---|
22 | iterator_property_map<<a href="http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>, OffsetMap, T, R>
|
---|
23 | </PRE>
|
---|
24 |
|
---|
25 | <P>
|
---|
26 | This property map is an adaptor that converts any random access
|
---|
27 | iterator into a <a
|
---|
28 | href="./LvaluePropertyMap.html">Lvalue Property Map</a>.
|
---|
29 | The <tt>OffsetMap</tt> type is responsible for converting
|
---|
30 | key objects to integers that can be used as offsets with the
|
---|
31 | random access iterator.
|
---|
32 | </P>
|
---|
33 |
|
---|
34 | <h3>Example</h3>
|
---|
35 |
|
---|
36 | <pre>
|
---|
37 | template <typename T>
|
---|
38 | typename boost::property_traits<T>::value_type get_value_three(T m)
|
---|
39 | {
|
---|
40 | return get(m, 3);
|
---|
41 | }
|
---|
42 |
|
---|
43 | int main()
|
---|
44 | {
|
---|
45 | typedef boost::identity_property_map id_map;
|
---|
46 | std::vector<int> fibo;
|
---|
47 |
|
---|
48 | fibo.push_back(1);
|
---|
49 | fibo.push_back(1);
|
---|
50 | fibo.push_back(2);
|
---|
51 | fibo.push_back(3);
|
---|
52 | fibo.push_back(5);
|
---|
53 | fibo.push_back(8);
|
---|
54 | fibo.push_back(13);
|
---|
55 |
|
---|
56 | boost::iterator_property_map< std::vector<int>::iterator, id_map> fibo_map(fibo.begin() + 2);
|
---|
57 |
|
---|
58 | std::cout << "The sixth fibonacci number is " << get_value_three(fibo_map) << std::endl;
|
---|
59 |
|
---|
60 | int primes[]={2,3,5,7,11,13,17};
|
---|
61 |
|
---|
62 | boost::iterator_property_map< int*, id_map, int, int&> prime_map(&primes[1]);</p>
|
---|
63 |
|
---|
64 | std::cout << "The fifth prime number is " << get_value_three(prime_map) <<std::endl;
|
---|
65 |
|
---|
66 | return 0;
|
---|
67 | }
|
---|
68 | </pre>
|
---|
69 |
|
---|
70 | <H3>Where Defined</H3>
|
---|
71 |
|
---|
72 | <P>
|
---|
73 | <a href="../../../boost/property_map/property_map.hpp"><TT>boost/property_map/property_map.hpp</TT></a>
|
---|
74 |
|
---|
75 | <p>
|
---|
76 | <H3>Model Of</H3>
|
---|
77 |
|
---|
78 | <a href="./LvaluePropertyMap.html">Lvalue Property Map</a>
|
---|
79 |
|
---|
80 | <P>
|
---|
81 |
|
---|
82 | <H3>Template Parameters</H3>
|
---|
83 |
|
---|
84 | <P>
|
---|
85 |
|
---|
86 | <TABLE border>
|
---|
87 | <TR>
|
---|
88 | <th>Parameter</th><th>Description</th><th>Default</th>
|
---|
89 | </tr>
|
---|
90 |
|
---|
91 |
|
---|
92 | <TR>
|
---|
93 | <TD><TT>Iterator</TT></TD>
|
---|
94 | <TD>Must be a model of <a href="http://www.sgi.com/tech/stl/RandomAccessIterator.html">Random Access Iterator</a>.</TD>
|
---|
95 | <TD> </td>
|
---|
96 | </tr>
|
---|
97 |
|
---|
98 | <TR>
|
---|
99 | <TD><TT>OffsetMap</TT></TD> <TD>Must be a model of <a
|
---|
100 | href="./ReadablePropertyMap.html">Readable Property Map</a>
|
---|
101 | and the value type must be convertible to the difference type of the
|
---|
102 | iterator.</TD> <TD> </TD>
|
---|
103 | </TR>
|
---|
104 |
|
---|
105 | <TR>
|
---|
106 | <TD><TT>T</TT></TD>
|
---|
107 | <TD>The value type of the iterator.</TD>
|
---|
108 | <TD><TT>std::iterator_traits<RandomAccessIterator>::value_type</TT></TD>
|
---|
109 | </TR>
|
---|
110 |
|
---|
111 |
|
---|
112 | <TR>
|
---|
113 | <TD><TT>R</TT></TD>
|
---|
114 | <TD>The reference type of the iterator.</TD>
|
---|
115 | <TD><TT>std::iterator_traits<RandomAccessIterator>::reference</TT></TD>
|
---|
116 | </TR>
|
---|
117 |
|
---|
118 | </TABLE>
|
---|
119 | <P>
|
---|
120 |
|
---|
121 | <H3>Members</H3>
|
---|
122 |
|
---|
123 | <P>
|
---|
124 | In addition to the methods and functions required by <a
|
---|
125 | href="./LvaluePropertyMap.html">Lvalue Property Map</a>, this
|
---|
126 | class has the following members.
|
---|
127 |
|
---|
128 | <hr>
|
---|
129 |
|
---|
130 | <pre>
|
---|
131 | property_traits<iterator_property_map>::value_type
|
---|
132 | </pre>
|
---|
133 | This is the same type as
|
---|
134 | <TT>std::iterator_traits<Iterator>::value_type</TT>.
|
---|
135 |
|
---|
136 | <hr>
|
---|
137 |
|
---|
138 | <pre>
|
---|
139 | iterator_property_map(Iterator i)
|
---|
140 | </pre>
|
---|
141 | Constructor. The OffsetMap is default constructed.
|
---|
142 |
|
---|
143 | <hr>
|
---|
144 |
|
---|
145 | <pre>
|
---|
146 | iterator_property_map(Iterator i, OffsetMap m)
|
---|
147 | </pre>
|
---|
148 | Constructor.
|
---|
149 |
|
---|
150 | <hr>
|
---|
151 |
|
---|
152 | <pre>
|
---|
153 | reference operator[](const key_type& v) const
|
---|
154 | </pre>
|
---|
155 | The operator bracket for property access. The <TT>reference</TT> is from
|
---|
156 | <TT>std::iterator_traits<Iterator></TT> and the <tt>key_type</tt> is from <tt>boost::property_traits<OffsetMap></tt>.
|
---|
157 | <hr>
|
---|
158 |
|
---|
159 | <h3>Non-Member functions</h3>
|
---|
160 |
|
---|
161 | <hr>
|
---|
162 |
|
---|
163 | <pre>
|
---|
164 | template <class RAIter, class OffsetMap>
|
---|
165 | iterator_property_map<RAIter, OffsetMap,
|
---|
166 | typename std::iterator_traits<RAIter>::value_type,
|
---|
167 | typename std::iterator_traits<RAIter>::reference
|
---|
168 | >
|
---|
169 | make_iterator_property_map(RAIter iter, OffsetMap omap)
|
---|
170 | </pre>
|
---|
171 | A function for conveniently creating an iterator map.
|
---|
172 |
|
---|
173 |
|
---|
174 | <hr>
|
---|
175 |
|
---|
176 | <pre>
|
---|
177 | template <class RAIter, class OffsetMap, class ValueType>
|
---|
178 | iterator_property_map<RAIter, OffsetMap,
|
---|
179 | typename std::iterator_traits<RAIter>::value_type,
|
---|
180 | typename std::iterator_traits<RAIter>::reference
|
---|
181 | >
|
---|
182 | make_iterator_property_map(RAIter iter, OffsetMap omap, ValueType dummy_arg)
|
---|
183 | </pre>
|
---|
184 | Use this function instead of the 2-argument version if
|
---|
185 | your compiler does not support partial specialization
|
---|
186 | (like Visual C++).
|
---|
187 |
|
---|
188 |
|
---|
189 | <hr>
|
---|
190 |
|
---|
191 |
|
---|
192 | <br>
|
---|
193 | <HR>
|
---|
194 | <TABLE>
|
---|
195 | <TR valign=top>
|
---|
196 | <TD nowrap>Copyright © 2000-2012</TD><TD>
|
---|
197 | <p>
|
---|
198 | <a HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</a>, Univ.of Notre Dame (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
---|
199 | <A HREF="http://www.boost.org/people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@osl.iu.edu">llee1@osl.iu.edu</A>)<br>
|
---|
200 | <A HREF="http://www.osl.iu.edu/~lums">Andrew Lumsdaine</A>, Univ.of Notre Dame (<A HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)<br>
|
---|
201 | Alex Hagen-Zanker
|
---|
202 | </p></TD></TR></TABLE>
|
---|
203 |
|
---|
204 | </BODY>
|
---|
205 | </HTML>
|
---|