• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>adjacent_filtered</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="../reference.html" title="Reference">
10<link rel="next" href="copied.html" title="copied">
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="../reference.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="copied.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.adaptors.reference.adjacent_filtered"></a><a class="link" href="adjacent_filtered.html" title="adjacent_filtered">adjacent_filtered</a>
28</h5></div></div></div>
29<div class="toc"><dl class="toc"><dt><span class="section"><a href="adjacent_filtered.html#range.reference.adaptors.reference.adjacent_filtered.adjacent_filtered_example">adjacent_filtered
30            example</a></span></dt></dl></div>
31<div class="informaltable"><table class="table">
32<colgroup>
33<col>
34<col>
35</colgroup>
36<thead><tr>
37<th>
38                    <p>
39                      Syntax
40                    </p>
41                  </th>
42<th>
43                    <p>
44                      Code
45                    </p>
46                  </th>
47</tr></thead>
48<tbody>
49<tr>
50<td>
51                    <p>
52                      Pipe
53                    </p>
54                  </td>
55<td>
56                    <p>
57                      <code class="computeroutput"><span class="identifier">rng</span> <span class="special">|</span>
58                      <span class="identifier">boost</span><span class="special">::</span><span class="identifier">adaptors</span><span class="special">::</span><span class="identifier">adjacent_filtered</span><span class="special">(</span><span class="identifier">bi_pred</span><span class="special">)</span></code>
59                    </p>
60                  </td>
61</tr>
62<tr>
63<td>
64                    <p>
65                      Function
66                    </p>
67                  </td>
68<td>
69                    <p>
70                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">adaptors</span><span class="special">::</span><span class="identifier">adjacent_filter</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span>
71                      <span class="identifier">bi_pred</span><span class="special">)</span></code>
72                    </p>
73                  </td>
74</tr>
75</tbody>
76</table></div>
77<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
78<li class="listitem">
79                <span class="bold"><strong>Precondition:</strong></span> The <code class="computeroutput"><span class="identifier">value_type</span></code> of the range is convertible
80                to both argument types of <code class="computeroutput"><span class="identifier">bi_pred</span></code>.
81              </li>
82<li class="listitem">
83                <span class="bold"><strong>Postcondition:</strong></span> For all adjacent
84                elements <code class="computeroutput"><span class="special">[</span><span class="identifier">x</span><span class="special">,</span><span class="identifier">y</span><span class="special">]</span></code> in the returned range, <code class="computeroutput"><span class="identifier">bi_pred</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span><span class="identifier">y</span><span class="special">)</span></code>
85                is <code class="computeroutput"><span class="keyword">true</span></code>.
86              </li>
87<li class="listitem">
88                <span class="bold"><strong>Throws:</strong></span> Whatever the copy constructor
89                of <code class="computeroutput"><span class="identifier">bi_pred</span></code> might
90                throw.
91              </li>
92<li class="listitem">
93                <span class="bold"><strong>Range Category:</strong></span> <a class="link" href="../../../concepts/forward_range.html" title="Forward Range">Forward
94                Range</a>
95              </li>
96<li class="listitem">
97                <span class="bold"><strong>Return Type:</strong></span> <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">adjacent_filtered_range</span><span class="special">&lt;</span><span class="keyword">decltype</span><span class="special">(</span><span class="identifier">rng</span><span class="special">),</span> <span class="keyword">decltype</span><span class="special">(</span><span class="identifier">bi_pred</span><span class="special">)&gt;</span></code>
98              </li>
99<li class="listitem">
100                <span class="bold"><strong>Returned Range Category:</strong></span> The minimum
101                of the range category of <code class="computeroutput"><span class="identifier">rng</span></code>
102                and <a class="link" href="../../../concepts/forward_range.html" title="Forward Range">Forward Range</a>
103              </li>
104</ul></div>
105<div class="section">
106<div class="titlepage"><div><div><h6 class="title">
107<a name="range.reference.adaptors.reference.adjacent_filtered.adjacent_filtered_example"></a><a class="link" href="adjacent_filtered.html#range.reference.adaptors.reference.adjacent_filtered.adjacent_filtered_example" title="adjacent_filtered example">adjacent_filtered
108            example</a>
109</h6></div></div></div>
110<p>
111</p>
112<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">range</span><span class="special">/</span><span class="identifier">adaptor</span><span class="special">/</span><span class="identifier">adjacent_filtered</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
113<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">range</span><span class="special">/</span><span class="identifier">algorithm</span><span class="special">/</span><span class="identifier">copy</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
114<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">assign</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
115<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iterator</span><span class="special">&gt;</span>
116<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">functional</span><span class="special">&gt;</span>
117<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
118<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">vector</span><span class="special">&gt;</span>
119
120<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">argc</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">argv</span><span class="special">[])</span>
121<span class="special">{</span>
122    <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">assign</span><span class="special">;</span>
123    <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">adaptors</span><span class="special">;</span>
124
125    <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">input</span><span class="special">;</span>
126    <span class="identifier">input</span> <span class="special">+=</span> <span class="number">1</span><span class="special">,</span><span class="number">1</span><span class="special">,</span><span class="number">2</span><span class="special">,</span><span class="number">2</span><span class="special">,</span><span class="number">2</span><span class="special">,</span><span class="number">3</span><span class="special">,</span><span class="number">4</span><span class="special">,</span><span class="number">5</span><span class="special">,</span><span class="number">6</span><span class="special">;</span>
127
128    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span>
129        <span class="identifier">input</span> <span class="special">|</span> <span class="identifier">adjacent_filtered</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">not_equal_to</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;()),</span>
130        <span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream_iterator</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">","</span><span class="special">));</span>
131
132    <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
133<span class="special">}</span>
134</pre>
135<p>
136            </p>
137</div>
138<p>
139            This would produce the output:
140</p>
141<pre class="programlisting"><span class="number">1</span><span class="special">,</span><span class="number">2</span><span class="special">,</span><span class="number">3</span><span class="special">,</span><span class="number">4</span><span class="special">,</span><span class="number">5</span><span class="special">,</span><span class="number">6</span><span class="special">,</span>
142</pre>
143<p>
144          </p>
145</div>
146<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
147<td align="left"></td>
148<td align="right"><div class="copyright-footer">Copyright © 2003-2010 Thorsten Ottosen,
149      Neil Groves<p>
150        Distributed under the Boost Software License, Version 1.0. (See accompanying
151        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>)
152      </p>
153</div></td>
154</tr></table>
155<hr>
156<div class="spirit-nav">
157<a accesskey="p" href="../reference.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="copied.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
158</div>
159</body>
160</html>
161