• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Function join</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="../utilities.html" title="Utilities">
9<link rel="prev" href="combine.html" title="Function combine">
10<link rel="next" href="../extending.html" title="Extending the library">
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="combine.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../utilities.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="../extending.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h4 class="title">
27<a name="range.reference.utilities.join"></a><a class="link" href="join.html" title="Function join">Function join</a>
28</h4></div></div></div>
29<p>
30          The intention of the <code class="computeroutput"><span class="identifier">join</span></code>
31          function is to join two ranges into one longer range.
32        </p>
33<p>
34          The resultant range will have the lowest common traversal of the two ranges
35          supplied as parameters.
36        </p>
37<p>
38          Note that the joined range incurs a performance cost due to the need to
39          check if the end of a range has been reached internally during traversal.
40        </p>
41<h5>
42<a name="range.reference.utilities.join.h0"></a>
43          <span class="phrase"><a name="range.reference.utilities.join.synopsis"></a></span><a class="link" href="join.html#range.reference.utilities.join.synopsis">Synopsis</a>
44        </h5>
45<p>
46</p>
47<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">SinglePassRange1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">SinglePassRange2</span><span class="special">&gt;</span>
48<span class="identifier">joined_range</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">SinglePassRange1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">SinglePassRange2</span><span class="special">&gt;</span>
49<span class="identifier">join</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">SinglePassRange1</span><span class="special">&amp;</span> <span class="identifier">rng1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">SinglePassRange2</span><span class="special">&amp;</span> <span class="identifier">rng2</span><span class="special">)</span>
50
51<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">SinglePassRange1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">SinglePassRange2</span><span class="special">&gt;</span>
52<span class="identifier">joined_range</span><span class="special">&lt;</span><span class="identifier">SinglePassRange1</span><span class="special">,</span> <span class="identifier">SinglePassRange2</span><span class="special">&gt;</span>
53<span class="identifier">join</span><span class="special">(</span><span class="identifier">SinglePassRange1</span><span class="special">&amp;</span> <span class="identifier">rng1</span><span class="special">,</span> <span class="identifier">SinglePassRange2</span><span class="special">&amp;</span> <span class="identifier">rng2</span><span class="special">);</span>
54</pre>
55<p>
56        </p>
57<p>
58          For the const version:
59        </p>
60<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
61<li class="listitem">
62              <span class="bold"><strong>Precondition:</strong></span> The <code class="computeroutput"><span class="identifier">range_value</span><span class="special">&lt;</span><span class="identifier">SinglePassRange2</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
63              must be convertible to <code class="computeroutput"><span class="identifier">range_value</span><span class="special">&lt;</span><span class="identifier">SinglePassRange1</span><span class="special">&gt;::</span><span class="identifier">type</span></code>.
64              The <code class="computeroutput"><span class="identifier">range_reference</span><span class="special">&lt;</span><span class="keyword">const</span>
65              <span class="identifier">SinglePassRange2</span><span class="special">&gt;::</span><span class="identifier">type</span></code> must be convertible to <code class="computeroutput"><span class="identifier">range_reference</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">SinglePassRange1</span><span class="special">&gt;::</span><span class="identifier">type</span></code>.
66            </li>
67<li class="listitem">
68              <span class="bold"><strong>Range Category:</strong></span> Both <code class="computeroutput"><span class="identifier">rng1</span></code> and <code class="computeroutput"><span class="identifier">rng2</span></code>
69              must be a model of <a class="link" href="../../concepts/single_pass_range.html" title="Single Pass Range">Single
70              Pass Range</a> or better.
71            </li>
72<li class="listitem">
73              <span class="bold"><strong>Range Return Type:</strong></span> <code class="computeroutput"><span class="identifier">joined_range</span><span class="special">&lt;</span><span class="keyword">const</span>
74              <span class="identifier">SinglePassRange1</span><span class="special">,</span>
75              <span class="keyword">const</span> <span class="identifier">SinglePassRange2</span><span class="special">&gt;</span></code> which is a model of the lesser
76              of the two range concepts passed.
77            </li>
78<li class="listitem">
79              <span class="bold"><strong>Returned Range Category:</strong></span> The minimum
80              of the range category of <code class="computeroutput"><span class="identifier">rng1</span></code>
81              and <code class="computeroutput"><span class="identifier">rng2</span></code>.
82            </li>
83</ul></div>
84<p>
85          For the mutable version:
86        </p>
87<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
88<li class="listitem">
89              <span class="bold"><strong>Precondition:</strong></span> The <code class="computeroutput"><span class="identifier">range_value</span><span class="special">&lt;</span><span class="identifier">SinglePassRange2</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
90              must be convertible to <code class="computeroutput"><span class="identifier">range_value</span><span class="special">&lt;</span><span class="identifier">SinglePassRange1</span><span class="special">&gt;::</span><span class="identifier">type</span></code>.
91              The <code class="computeroutput"><span class="identifier">range_reference</span><span class="special">&lt;</span><span class="identifier">SinglePassRange2</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
92              must be convertible to <code class="computeroutput"><span class="identifier">range_reference</span><span class="special">&lt;</span><span class="identifier">SinglePassRange1</span><span class="special">&gt;::</span><span class="identifier">type</span></code>.
93            </li>
94<li class="listitem">
95              <span class="bold"><strong>Range Category:</strong></span> Both <code class="computeroutput"><span class="identifier">rng1</span></code> and <code class="computeroutput"><span class="identifier">rng2</span></code>
96              must be a model of <a class="link" href="../../concepts/single_pass_range.html" title="Single Pass Range">Single
97              Pass Range</a> or better.
98            </li>
99<li class="listitem">
100              <span class="bold"><strong>Range Return Type:</strong></span> <code class="computeroutput"><span class="identifier">joined_range</span><span class="special">&lt;</span><span class="identifier">SinglePassRange1</span><span class="special">,</span> <span class="identifier">SinglePassRange2</span><span class="special">&gt;</span></code> which is a model of the lesser
101              of the two range concepts passed.
102            </li>
103<li class="listitem">
104              <span class="bold"><strong>Returned Range Category:</strong></span> The minimum
105              of the range category of <code class="computeroutput"><span class="identifier">rng1</span></code>
106              and <code class="computeroutput"><span class="identifier">rng2</span></code>.
107            </li>
108</ul></div>
109<h5>
110<a name="range.reference.utilities.join.h1"></a>
111          <span class="phrase"><a name="range.reference.utilities.join.example"></a></span><a class="link" href="join.html#range.reference.utilities.join.example">Example</a>
112        </h5>
113<p>
114          The expression <code class="computeroutput"><span class="identifier">join</span><span class="special">(</span><span class="identifier">irange</span><span class="special">(</span><span class="number">0</span><span class="special">,</span><span class="number">5</span><span class="special">),</span> <span class="identifier">irange</span><span class="special">(</span><span class="number">5</span><span class="special">,</span><span class="number">10</span><span class="special">))</span></code> would
115          evaluate to a range representing an integer range <code class="computeroutput"><span class="special">[</span><span class="number">0</span><span class="special">,</span><span class="number">10</span><span class="special">)</span></code>
116        </p>
117</div>
118<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
119<td align="left"></td>
120<td align="right"><div class="copyright-footer">Copyright © 2003-2010 Thorsten Ottosen,
121      Neil Groves<p>
122        Distributed under the Boost Software License, Version 1.0. (See accompanying
123        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>)
124      </p>
125</div></td>
126</tr></table>
127<hr>
128<div class="spirit-nav">
129<a accesskey="p" href="combine.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../utilities.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="../extending.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
130</div>
131</body>
132</html>
133