• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Functions</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. Range 2.0">
8<link rel="up" href="../semantics.html" title="Semantics">
9<link rel="prev" href="metafunctions.html" title="Metafunctions">
10<link rel="next" href="../../adaptors.html" title="Range Adaptors">
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="metafunctions.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../semantics.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="../../adaptors.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h5 class="title">
27<a name="range.reference.concept_implementation.semantics.functions"></a><a class="link" href="functions.html" title="Functions">Functions</a>
28</h5></div></div></div>
29<div class="informaltable"><table class="table">
30<colgroup>
31<col>
32<col>
33<col>
34</colgroup>
35<thead><tr>
36<th>
37                    <p>
38                      Expression
39                    </p>
40                  </th>
41<th>
42                    <p>
43                      Return type
44                    </p>
45                  </th>
46<th>
47                    <p>
48                      Returns
49                    </p>
50                  </th>
51<th>
52                    <p>
53                      Complexity
54                    </p>
55                  </th>
56</tr></thead>
57<tbody>
58<tr>
59<td>
60                    <p>
61                      <code class="computeroutput"><span class="identifier">begin</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
62                    </p>
63                  </td>
64<td>
65                    <p>
66                      <code class="computeroutput"><span class="identifier">range_iterator</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
67                    </p>
68                  </td>
69<td>
70                    <p>
71                      <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span></code> if <code class="computeroutput"><span class="identifier">p</span></code>
72                      is of type <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> <code class="computeroutput"><span class="identifier">a</span></code>
73                      if <code class="computeroutput"><span class="identifier">a</span></code> is an
74                      array <code class="computeroutput"><span class="identifier">range_begin</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code> if that expression would invoke
75                      a function found by ADL <code class="computeroutput"><span class="identifier">t</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span></code> otherwise
76                    </p>
77                  </td>
78<td>
79                    <p>
80                      constant time
81                    </p>
82                  </td>
83</tr>
84<tr>
85<td>
86                    <p>
87                      <code class="computeroutput"><span class="identifier">end</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
88                    </p>
89                  </td>
90<td>
91                    <p>
92                      <code class="computeroutput"><span class="identifier">range_iterator</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
93                    </p>
94                  </td>
95<td>
96                    <p>
97                      <code class="computeroutput"><span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span></code> if <code class="computeroutput"><span class="identifier">p</span></code>
98                      is of type <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> <code class="computeroutput"><span class="identifier">a</span>
99                      <span class="special">+</span> <span class="identifier">sz</span></code>
100                      if <code class="computeroutput"><span class="identifier">a</span></code> is an
101                      array of size <code class="computeroutput"><span class="identifier">sz</span></code>
102                      <code class="computeroutput"><span class="identifier">range_end</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
103                      if that expression would invoke a function found by ADL <code class="computeroutput"><span class="identifier">t</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span></code>
104                      otherwise
105                    </p>
106                  </td>
107<td>
108                    <p>
109                      constant time
110                    </p>
111                  </td>
112</tr>
113<tr>
114<td>
115                    <p>
116                      <code class="computeroutput"><span class="identifier">empty</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
117                    </p>
118                  </td>
119<td>
120                    <p>
121                      <code class="computeroutput"><span class="keyword">bool</span></code>
122                    </p>
123                  </td>
124<td>
125                    <p>
126                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span>
127                      <span class="special">==</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">end</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
128                    </p>
129                  </td>
130<td>
131                    <p>
132                      constant time
133                    </p>
134                  </td>
135</tr>
136<tr>
137<td>
138                    <p>
139                      <code class="computeroutput"><span class="identifier">distance</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
140                    </p>
141                  </td>
142<td>
143                    <p>
144                      <code class="computeroutput"><span class="identifier">range_difference</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
145                    </p>
146                  </td>
147<td>
148                    <p>
149                      <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">distance</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">x</span><span class="special">),</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">end</span><span class="special">(</span><span class="identifier">x</span><span class="special">))</span></code>
150                    </p>
151                  </td>
152<td>
153                    <p>
154                      -
155                    </p>
156                  </td>
157</tr>
158<tr>
159<td>
160                    <p>
161                      <code class="computeroutput"><span class="identifier">size</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
162                    </p>
163                  </td>
164<td>
165                    <p>
166                      <code class="computeroutput"><span class="identifier">range_size</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
167                    </p>
168                  </td>
169<td>
170                    <p>
171                      <code class="computeroutput"><span class="identifier">range_calculate_size</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code> which by default is <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">end</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span>
172                      <span class="special">-</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>. Users may supply alternative
173                      implementations by implementing <code class="computeroutput"><span class="identifier">range_calculate_size</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code> so that it will be found via
174                      ADL
175                    </p>
176                  </td>
177<td>
178                    <p>
179                      constant time
180                    </p>
181                  </td>
182</tr>
183<tr>
184<td>
185                    <p>
186                      <code class="computeroutput"><span class="identifier">rbegin</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
187                    </p>
188                  </td>
189<td>
190                    <p>
191                      <code class="computeroutput"><span class="identifier">range_reverse_iterator</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
192                    </p>
193                  </td>
194<td>
195                    <p>
196                      <code class="computeroutput"><span class="identifier">range_reverse_iterator</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">end</span><span class="special">(</span><span class="identifier">x</span><span class="special">))</span></code>
197                    </p>
198                  </td>
199<td>
200                    <p>
201                      constant time
202                    </p>
203                  </td>
204</tr>
205<tr>
206<td>
207                    <p>
208                      <code class="computeroutput"><span class="identifier">rend</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
209                    </p>
210                  </td>
211<td>
212                    <p>
213                      <code class="computeroutput"><span class="identifier">range_reverse_iterator</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
214                    </p>
215                  </td>
216<td>
217                    <p>
218                      <code class="computeroutput"><span class="identifier">range_reverse_iterator</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">x</span><span class="special">))</span></code>
219                    </p>
220                  </td>
221<td>
222                    <p>
223                      constant time
224                    </p>
225                  </td>
226</tr>
227<tr>
228<td>
229                    <p>
230                      <code class="computeroutput"><span class="identifier">const_begin</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
231                    </p>
232                  </td>
233<td>
234                    <p>
235                      <code class="computeroutput"><span class="identifier">range_iterator</span><span class="special">&lt;</span><span class="keyword">const</span>
236                      <span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
237                    </p>
238                  </td>
239<td>
240                    <p>
241                      <code class="computeroutput"><span class="identifier">range_iterator</span><span class="special">&lt;</span><span class="keyword">const</span>
242                      <span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">x</span><span class="special">))</span></code>
243                    </p>
244                  </td>
245<td>
246                    <p>
247                      constant time
248                    </p>
249                  </td>
250</tr>
251<tr>
252<td>
253                    <p>
254                      <code class="computeroutput"><span class="identifier">const_end</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
255                    </p>
256                  </td>
257<td>
258                    <p>
259                      <code class="computeroutput"><span class="identifier">range_iterator</span><span class="special">&lt;</span><span class="keyword">const</span>
260                      <span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
261                    </p>
262                  </td>
263<td>
264                    <p>
265                      <code class="computeroutput"><span class="identifier">range_iterator</span><span class="special">&lt;</span><span class="keyword">const</span>
266                      <span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">end</span><span class="special">(</span><span class="identifier">x</span><span class="special">))</span></code>
267                    </p>
268                  </td>
269<td>
270                    <p>
271                      constant time
272                    </p>
273                  </td>
274</tr>
275<tr>
276<td>
277                    <p>
278                      <code class="computeroutput"><span class="identifier">const_rbegin</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
279                    </p>
280                  </td>
281<td>
282                    <p>
283                      <code class="computeroutput"><span class="identifier">range_reverse_iterator</span><span class="special">&lt;</span><span class="keyword">const</span>
284                      <span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
285                    </p>
286                  </td>
287<td>
288                    <p>
289                      <code class="computeroutput"><span class="identifier">range_reverse_iterator</span><span class="special">&lt;</span><span class="keyword">const</span>
290                      <span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">rbegin</span><span class="special">(</span><span class="identifier">x</span><span class="special">))</span></code>
291                    </p>
292                  </td>
293<td>
294                    <p>
295                      constant time
296                    </p>
297                  </td>
298</tr>
299<tr>
300<td>
301                    <p>
302                      <code class="computeroutput"><span class="identifier">const_rend</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
303                    </p>
304                  </td>
305<td>
306                    <p>
307                      <code class="computeroutput"><span class="identifier">range_reverse_iterator</span><span class="special">&lt;</span><span class="keyword">const</span>
308                      <span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
309                    </p>
310                  </td>
311<td>
312                    <p>
313                      <code class="computeroutput"><span class="identifier">range_reverse_iterator</span><span class="special">&lt;</span><span class="keyword">const</span>
314                      <span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">rend</span><span class="special">(</span><span class="identifier">x</span><span class="special">))</span></code>
315                    </p>
316                  </td>
317<td>
318                    <p>
319                      constant time
320                    </p>
321                  </td>
322</tr>
323<tr>
324<td>
325                    <p>
326                      <code class="computeroutput"><span class="identifier">as_literal</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
327                    </p>
328                  </td>
329<td>
330                    <p>
331                      <code class="computeroutput"><span class="identifier">iterator_range</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span></code> where <code class="computeroutput"><span class="identifier">U</span></code>
332                      is <code class="computeroutput"><span class="identifier">Char</span><span class="special">*</span></code>
333                      if <code class="computeroutput"><span class="identifier">x</span></code> is a pointer
334                      to a string and <code class="computeroutput"><span class="identifier">U</span></code>
335                      is <code class="computeroutput"><span class="identifier">range_iterator</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
336                      otherwise
337                    </p>
338                  </td>
339<td>
340                    <p>
341                      <code class="computeroutput"><span class="special">[</span><span class="identifier">s</span><span class="special">,</span><span class="identifier">s</span>
342                      <span class="special">+</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">char_traits</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">length</span><span class="special">(</span><span class="identifier">s</span><span class="special">))</span></code> if <code class="computeroutput"><span class="identifier">s</span></code>
343                      is a <code class="computeroutput"><span class="identifier">Char</span><span class="special">*</span></code>
344                      or an array of <code class="computeroutput"><span class="identifier">Char</span></code>
345                      <code class="computeroutput"><span class="special">[</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">x</span><span class="special">),</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">end</span><span class="special">(</span><span class="identifier">x</span><span class="special">))</span></code> otherwise
346                    </p>
347                  </td>
348<td>
349                    <p>
350                      linear time for pointers to a string or arrays of <code class="computeroutput"><span class="identifier">Char</span></code>, constant time otherwise
351                    </p>
352                  </td>
353</tr>
354<tr>
355<td>
356                    <p>
357                      <code class="computeroutput"><span class="identifier">as_array</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
358                    </p>
359                  </td>
360<td>
361                    <p>
362                      <code class="computeroutput"><span class="identifier">iterator_range</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;</span></code>
363                    </p>
364                  </td>
365<td>
366                    <p>
367                      <code class="computeroutput"><span class="special">[</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">x</span><span class="special">),</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">end</span><span class="special">(</span><span class="identifier">x</span><span class="special">))</span></code>
368                    </p>
369                  </td>
370</tr>
371</tbody>
372</table></div>
373<p>
374            The special <code class="computeroutput"><span class="identifier">const_</span></code>-named
375            functions are useful when you want to document clearly that your code
376            is read-only.
377          </p>
378<p>
379            <code class="computeroutput"><span class="identifier">as_literal</span><span class="special">()</span></code>
380            can be used <span class="emphasis"><em><span class="bold"><strong>internally</strong></span></em></span>
381            in string algorithm libraries such that arrays of characters are handled
382            correctly.
383          </p>
384<p>
385            <code class="computeroutput"><span class="identifier">as_array</span><span class="special">()</span></code>
386            can be used with string algorithm libraries to make it clear that arrays
387            of characters are handled like an array and not like a string.
388          </p>
389<p>
390            Notice that the above functions should always be called with qualification
391            (<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span></code>)
392            to prevent <span class="emphasis"><em><span class="bold"><strong>unintended</strong></span></em></span>
393            Argument Dependent Lookup (ADL).
394          </p>
395</div>
396<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
397<td align="left"></td>
398<td align="right"><div class="copyright-footer">Copyright © 2003-2010 Thorsten Ottosen,
399      Neil Groves<p>
400        Distributed under the Boost Software License, Version 1.0. (See accompanying
401        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
402      </p>
403</div></td>
404</tr></table>
405<hr>
406<div class="spirit-nav">
407<a accesskey="p" href="metafunctions.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../semantics.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="../../adaptors.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
408</div>
409</body>
410</html>
411