• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>uniqued</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="transformed.html" title="transformed">
10<link rel="next" href="../../algorithms.html" title="Range Algorithms">
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="transformed.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="../../algorithms.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.uniqued"></a><a class="link" href="uniqued.html" title="uniqued">uniqued</a>
28</h5></div></div></div>
29<div class="toc"><dl class="toc"><dt><span class="section"><a href="uniqued.html#range.reference.adaptors.reference.uniqued.uniqued_example">uniqued
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">uniqued</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">unique</span><span class="special">(</span><span class="identifier">rng</span><span class="special">)</span></code>
71                    </p>
72                  </td>
73</tr>
74</tbody>
75</table></div>
76<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
77<li class="listitem">
78                <span class="bold"><strong>Precondition:</strong></span> The <code class="computeroutput"><span class="identifier">value_type</span></code> of the range is comparable
79                with <code class="computeroutput"><span class="keyword">operator</span><span class="special">==()</span></code>.
80              </li>
81<li class="listitem">
82                <span class="bold"><strong>Postcondition:</strong></span> For all adjacent
83                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">x</span><span class="special">==</span><span class="identifier">y</span></code> is false.
84              </li>
85<li class="listitem">
86                <span class="bold"><strong>Range Category:</strong></span> <a class="link" href="../../../concepts/forward_range.html" title="Forward Range">Forward
87                Range</a>
88              </li>
89<li class="listitem">
90                <span class="bold"><strong>Range Return Type:</strong></span> <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">uniqued_range</span><span class="special">&lt;</span><span class="keyword">decltype</span><span class="special">(</span><span class="identifier">rng</span><span class="special">)&gt;</span></code>
91              </li>
92<li class="listitem">
93                <span class="bold"><strong>Returned Range Category:</strong></span> The minimum
94                of the range concept of <code class="computeroutput"><span class="identifier">rng</span></code>
95                and <a class="link" href="../../../concepts/forward_range.html" title="Forward Range">Forward Range</a>.
96              </li>
97</ul></div>
98<div class="section">
99<div class="titlepage"><div><div><h6 class="title">
100<a name="range.reference.adaptors.reference.uniqued.uniqued_example"></a><a class="link" href="uniqued.html#range.reference.adaptors.reference.uniqued.uniqued_example" title="uniqued example">uniqued
101            example</a>
102</h6></div></div></div>
103<p>
104</p>
105<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">uniqued</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
106<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>
107<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>
108<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iterator</span><span class="special">&gt;</span>
109<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
110<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">vector</span><span class="special">&gt;</span>
111
112<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>
113<span class="special">{</span>
114    <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>
115    <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>
116
117    <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>
118    <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>
119
120    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span>
121        <span class="identifier">input</span> <span class="special">|</span> <span class="identifier">uniqued</span><span class="special">,</span>
122        <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>
123
124    <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
125<span class="special">}</span>
126</pre>
127<p>
128            </p>
129</div>
130<p>
131            This would produce the output:
132</p>
133<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>
134</pre>
135<p>
136          </p>
137</div>
138<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
139<td align="left"></td>
140<td align="right"><div class="copyright-footer">Copyright © 2003-2010 Thorsten Ottosen,
141      Neil Groves<p>
142        Distributed under the Boost Software License, Version 1.0. (See accompanying
143        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>)
144      </p>
145</div></td>
146</tr></table>
147<hr>
148<div class="spirit-nav">
149<a accesskey="p" href="transformed.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="../../algorithms.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
150</div>
151</body>
152</html>
153