1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Utilities</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="../reference.html" title="Reference"> 9<link rel="prev" href="ranges/irange.html" title="irange"> 10<link rel="next" href="utilities/iterator_range.html" title="Class iterator_range"> 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="ranges/irange.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.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="utilities/iterator_range.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h3 class="title"> 27<a name="range.reference.utilities"></a><a class="link" href="utilities.html" title="Utilities">Utilities</a> 28</h3></div></div></div> 29<div class="toc"><dl class="toc"> 30<dt><span class="section"><a href="utilities/iterator_range.html">Class <code class="computeroutput"><span class="identifier">iterator_range</span></code></a></span></dt> 31<dt><span class="section"><a href="utilities/sub_range.html">Class <code class="computeroutput"><span class="identifier">sub_range</span></code></a></span></dt> 32<dt><span class="section"><a href="utilities/combine.html">Function combine</a></span></dt> 33<dt><span class="section"><a href="utilities/join.html">Function join</a></span></dt> 34</dl></div> 35<p> 36 Having an abstraction that encapsulates a pair of iterators is very useful. 37 The standard library uses <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span></code> 38 in some circumstances, but that class is cumbersome to use because we need 39 to specify two template arguments, and for all range algorithm purposes we 40 must enforce the two template arguments to be the same. Moreover, <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span><span class="identifier">iterator</span><span class="special">></span></code> is hardly self-documenting whereas more 41 domain specific class names are. Therefore these two classes are provided: 42 </p> 43<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 44<li class="listitem"> 45 Class <code class="computeroutput"><span class="identifier">iterator_range</span></code> 46 </li> 47<li class="listitem"> 48 Class <code class="computeroutput"><span class="identifier">sub_range</span></code> 49 </li> 50<li class="listitem"> 51 Function <code class="computeroutput"><span class="identifier">combine</span></code> 52 </li> 53<li class="listitem"> 54 Function <code class="computeroutput"><span class="identifier">join</span></code> 55 </li> 56</ul></div> 57<p> 58 The <code class="computeroutput"><span class="identifier">iterator_range</span></code> class 59 is templated on an <a href="../../../../../../libs/iterator/doc/new-iter-concepts.html#forward-traversal-iterators-lib-forward-traversal-iterators" target="_top">Forward 60 Traversal Iterator</a> and should be used whenever fairly general code 61 is needed. The <code class="computeroutput"><span class="identifier">sub_range</span></code> 62 class is templated on an <a class="link" href="../concepts/forward_range.html" title="Forward Range">Forward 63 Range</a> and it is less general, but a bit easier to use since its template 64 argument is easier to specify. The biggest difference is, however, that a 65 <code class="computeroutput"><span class="identifier">sub_range</span></code> can propagate constness 66 because it knows what a corresponding <code class="computeroutput"><span class="identifier">const_iterator</span></code> 67 is. 68 </p> 69<p> 70 Both classes can be used as ranges since they implement the <a class="link" href="extending.html" title="Extending the library">minimal 71 interface</a> required for this to work automatically. 72 </p> 73</div> 74<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 75<td align="left"></td> 76<td align="right"><div class="copyright-footer">Copyright © 2003-2010 Thorsten Ottosen, 77 Neil Groves<p> 78 Distributed under the Boost Software License, Version 1.0. (See accompanying 79 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>) 80 </p> 81</div></td> 82</tr></table> 83<hr> 84<div class="spirit-nav"> 85<a accesskey="p" href="ranges/irange.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.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="utilities/iterator_range.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 86</div> 87</body> 88</html> 89