forked from boostorg/range
[range] Merge documentation fixes and minor refactoring of docs (refs #5160; refs #5314; refs #5440; refs #5775; refs #6212; refs #7585; refs #7843; refs #7866).
[SVN r82487]
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
[section:general General]
|
[section:general General]
|
||||||
[table
|
[table
|
||||||
[[Header ] [Includes ] [Related Concept ]]
|
[[Header ] [Includes ] [Related Concept ]]
|
||||||
[[`<boost/range.hpp>` ] [everything from Boost.Range version 1 (Boost versions 1.42 and below). Includes the core range functions and metafunctinos, but excludes Range Adaptors and Range Algorithms. ] [- ]]
|
[[`<boost/range.hpp>` ] [everything from Boost.Range version 1 (Boost versions 1.42 and below). Includes the core range functions and metafunctions, but excludes Range Adaptors and Range Algorithms. ] [- ]]
|
||||||
[[`<boost/range/metafunctions.hpp>` ] [every metafunction ] [- ]]
|
[[`<boost/range/metafunctions.hpp>` ] [every metafunction ] [- ]]
|
||||||
[[`<boost/range/functions.hpp>` ] [every function ] [- ]]
|
[[`<boost/range/functions.hpp>` ] [every function ] [- ]]
|
||||||
[[`<boost/range/value_type.hpp>` ] [__range_value__ ] [__single_pass_range__ ]]
|
[[`<boost/range/value_type.hpp>` ] [__range_value__ ] [__single_pass_range__ ]]
|
||||||
|
@ -147,7 +147,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"><p><small>Last revised: December 13, 2012 at 06:53:49 GMT</small></p></td>
|
<td align="left"><p><small>Last revised: January 14, 2013 at 08:50:06 GMT</small></p></td>
|
||||||
<td align="right"><div class="copyright-footer"></div></td>
|
<td align="right"><div class="copyright-footer"></div></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<p>
|
<p>
|
||||||
everything from Boost.Range version 1 (Boost versions 1.42 and
|
everything from Boost.Range version 1 (Boost versions 1.42 and
|
||||||
below). Includes the core range functions and metafunctinos, but
|
below). Includes the core range functions and metafunctions, but
|
||||||
excludes Range Adaptors and Range Algorithms.
|
excludes Range Adaptors and Range Algorithms.
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
|
@ -204,7 +204,7 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">int</span><span class="special">></span> <span class="identifier">vec</span><span class="special">;</span>
|
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">int</span><span class="special">></span> <span class="identifier">vec</span><span class="special">;</span>
|
||||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">replace_copy_if</span><span class="special">(</span> <span class="identifier">rng</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">back_inserter</span><span class="special">(</span><span class="identifier">vec</span><span class="special">),</span> <span class="identifier">pred</span> <span class="special">);</span>
|
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">replace_copy_if</span><span class="special">(</span> <span class="identifier">rng</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">back_inserter</span><span class="special">(</span><span class="identifier">vec</span><span class="special">),</span> <span class="identifier">pred</span><span class="special">,</span> <span class="identifier">new_value</span> <span class="special">);</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
|
@ -112,7 +112,7 @@
|
|||||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iterator</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">functional</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">functional</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
||||||
@ -138,7 +138,7 @@
|
|||||||
<p>
|
<p>
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
</p>
|
</p>
|
||||||
<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>
|
<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>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
|
@ -109,7 +109,7 @@
|
|||||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">copied</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">copied</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iterator</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
||||||
|
|
||||||
@ -134,7 +134,7 @@
|
|||||||
<p>
|
<p>
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><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>
|
<pre class="programlisting"><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>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
|
@ -112,7 +112,7 @@
|
|||||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">filtered</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">filtered</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iterator</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
||||||
|
|
||||||
@ -132,6 +132,8 @@
|
|||||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span>
|
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span>
|
||||||
<span class="identifier">input</span> <span class="special">|</span> <span class="identifier">filtered</span><span class="special">(</span><span class="identifier">is_even</span><span class="special">()),</span>
|
<span class="identifier">input</span> <span class="special">|</span> <span class="identifier">filtered</span><span class="special">(</span><span class="identifier">is_even</span><span class="special">()),</span>
|
||||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream_iterator</span><span class="special"><</span><span class="keyword">int</span><span class="special">>(</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>
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream_iterator</span><span class="special"><</span><span class="keyword">int</span><span class="special">>(</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>
|
||||||
|
|
||||||
|
<span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
|
||||||
<span class="special">}</span>
|
<span class="special">}</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
@ -140,7 +142,7 @@
|
|||||||
<p>
|
<p>
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="number">2</span><span class="special">,</span><span class="number">4</span><span class="special">,</span><span class="number">6</span><span class="special">,</span><span class="number">8</span>
|
<pre class="programlisting"><span class="number">2</span><span class="special">,</span><span class="number">4</span><span class="special">,</span><span class="number">6</span><span class="special">,</span><span class="number">8</span><span class="special">,</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<p>
|
<p>
|
||||||
<code class="computeroutput"><span class="identifier">rng</span> <span class="special">|</span>
|
<code class="computeroutput"><span class="identifier">rng</span> <span class="special">|</span>
|
||||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">adaptors</span><span class="special">::</span><span class="identifier">indexed</span></code>
|
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">adaptors</span><span class="special">::</span><span class="identifier">indexed</span><span class="special">(</span><span class="identifier">start_index</span><span class="special">)</span></code>
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -67,7 +67,8 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>
|
<p>
|
||||||
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">adaptors</span><span class="special">::</span><span class="identifier">index</span><span class="special">(</span><span class="identifier">rng</span><span class="special">)</span></code>
|
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">adaptors</span><span class="special">::</span><span class="identifier">index</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span>
|
||||||
|
<span class="identifier">start_index</span><span class="special">)</span></code>
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -104,7 +105,7 @@
|
|||||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">indexed</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">indexed</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iterator</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
||||||
|
|
||||||
@ -123,27 +124,6 @@
|
|||||||
<span class="identifier">display_element_and_index</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">rng</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">rng</span><span class="special">));</span>
|
<span class="identifier">display_element_and_index</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">rng</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">rng</span><span class="special">));</span>
|
||||||
<span class="special">}</span>
|
<span class="special">}</span>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Iterator1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Iterator2</span><span class="special">></span>
|
|
||||||
<span class="keyword">void</span> <span class="identifier">check_element_and_index</span><span class="special">(</span>
|
|
||||||
<span class="identifier">Iterator1</span> <span class="identifier">test_first</span><span class="special">,</span>
|
|
||||||
<span class="identifier">Iterator1</span> <span class="identifier">test_last</span><span class="special">,</span>
|
|
||||||
<span class="identifier">Iterator2</span> <span class="identifier">reference_first</span><span class="special">,</span>
|
|
||||||
<span class="identifier">Iterator2</span> <span class="identifier">reference_last</span><span class="special">)</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">distance</span><span class="special">(</span><span class="identifier">test_first</span><span class="special">,</span> <span class="identifier">test_last</span><span class="special">),</span>
|
|
||||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">distance</span><span class="special">(</span><span class="identifier">reference_first</span><span class="special">,</span> <span class="identifier">reference_last</span><span class="special">)</span> <span class="special">);</span>
|
|
||||||
|
|
||||||
<span class="keyword">int</span> <span class="identifier">reference_index</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
|
|
||||||
|
|
||||||
<span class="identifier">Iterator1</span> <span class="identifier">test_it</span> <span class="special">=</span> <span class="identifier">test_first</span><span class="special">;</span>
|
|
||||||
<span class="identifier">Iterator2</span> <span class="identifier">reference_it</span> <span class="special">=</span> <span class="identifier">reference_first</span><span class="special">;</span>
|
|
||||||
<span class="keyword">for</span> <span class="special">(;</span> <span class="identifier">test_it</span> <span class="special">!=</span> <span class="identifier">test_last</span><span class="special">;</span> <span class="special">++</span><span class="identifier">test_it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">reference_it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">reference_index</span><span class="special">)</span>
|
|
||||||
<span class="special">{</span>
|
|
||||||
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*</span><span class="identifier">test_it</span><span class="special">,</span> <span class="special">*</span><span class="identifier">reference_it</span> <span class="special">);</span>
|
|
||||||
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="identifier">test_it</span><span class="special">.</span><span class="identifier">index</span><span class="special">(),</span> <span class="identifier">reference_index</span> <span class="special">);</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
<span class="special">}</span>
|
|
||||||
|
|
||||||
<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>
|
<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>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
<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>
|
<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>
|
||||||
|
@ -108,7 +108,7 @@
|
|||||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">indirected</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">indirected</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">shared_ptr</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">shared_ptr</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iterator</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
||||||
|
|
||||||
@ -134,7 +134,7 @@
|
|||||||
<p>
|
<p>
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="number">0</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">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><span class="number">7</span><span class="special">,</span><span class="number">8</span><span class="special">,</span><span class="number">9</span>
|
<pre class="programlisting"><span class="number">0</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">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><span class="number">7</span><span class="special">,</span><span class="number">8</span><span class="special">,</span><span class="number">9</span><span class="special">,</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
|
@ -107,7 +107,7 @@
|
|||||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">map</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">map</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iterator</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">map</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">map</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
||||||
@ -134,7 +134,7 @@
|
|||||||
<p>
|
<p>
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="number">0</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">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><span class="number">7</span><span class="special">,</span><span class="number">8</span><span class="special">,</span><span class="number">9</span>
|
<pre class="programlisting"><span class="number">0</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">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><span class="number">7</span><span class="special">,</span><span class="number">8</span><span class="special">,</span><span class="number">9</span><span class="special">,</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
|
@ -109,7 +109,7 @@
|
|||||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">map</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">map</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iterator</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">map</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">map</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
||||||
@ -136,7 +136,7 @@
|
|||||||
<p>
|
<p>
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="number">0</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">20</span><span class="special">,</span><span class="number">30</span><span class="special">,</span><span class="number">40</span><span class="special">,</span><span class="number">50</span><span class="special">,</span><span class="number">60</span><span class="special">,</span><span class="number">70</span><span class="special">,</span><span class="number">80</span><span class="special">,</span><span class="number">90</span>
|
<pre class="programlisting"><span class="number">0</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">20</span><span class="special">,</span><span class="number">30</span><span class="special">,</span><span class="number">40</span><span class="special">,</span><span class="number">50</span><span class="special">,</span><span class="number">60</span><span class="special">,</span><span class="number">70</span><span class="special">,</span><span class="number">80</span><span class="special">,</span><span class="number">90</span><span class="special">,</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
|
@ -125,7 +125,7 @@
|
|||||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">replaced</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">replaced</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iterator</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
||||||
|
|
||||||
@ -150,7 +150,7 @@
|
|||||||
<p>
|
<p>
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="number">1</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">3</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">5</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">7</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">9</span>
|
<pre class="programlisting"><span class="number">1</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">3</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">5</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">7</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">9</span><span class="special">,</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
|
@ -121,7 +121,7 @@
|
|||||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">replaced_if</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">replaced_if</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iterator</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
||||||
|
|
||||||
@ -151,7 +151,7 @@
|
|||||||
<p>
|
<p>
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="number">1</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">3</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">5</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">7</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">9</span>
|
<pre class="programlisting"><span class="number">1</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">3</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">5</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">7</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">9</span><span class="special">,</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
|
@ -100,11 +100,11 @@
|
|||||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">reversed</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">reversed</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iterator</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
||||||
|
|
||||||
<span class="keyword">void</span> <span class="identifier">reversed_example_test</span><span class="special">()</span>
|
<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>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
<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>
|
<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>
|
||||||
<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>
|
<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>
|
||||||
@ -125,7 +125,7 @@
|
|||||||
<p>
|
<p>
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="number">9</span><span class="special">,</span><span class="number">8</span><span class="special">,</span><span class="number">7</span><span class="special">,</span><span class="number">6</span><span class="special">,</span><span class="number">5</span><span class="special">,</span><span class="number">4</span><span class="special">,</span><span class="number">3</span><span class="special">,</span><span class="number">2</span><span class="special">,</span><span class="number">1</span>
|
<pre class="programlisting"><span class="number">9</span><span class="special">,</span><span class="number">8</span><span class="special">,</span><span class="number">7</span><span class="special">,</span><span class="number">6</span><span class="special">,</span><span class="number">5</span><span class="special">,</span><span class="number">4</span><span class="special">,</span><span class="number">3</span><span class="special">,</span><span class="number">2</span><span class="special">,</span><span class="number">1</span><span class="special">,</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
|
@ -110,7 +110,7 @@
|
|||||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">sliced</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">sliced</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iterator</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
||||||
|
|
||||||
@ -135,7 +135,7 @@
|
|||||||
<p>
|
<p>
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="number">3</span><span class="special">,</span><span class="number">4</span><span class="special">,</span><span class="number">5</span>
|
<pre class="programlisting"><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>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
|
@ -102,7 +102,7 @@
|
|||||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">strided</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">strided</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iterator</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
||||||
|
|
||||||
@ -127,7 +127,7 @@
|
|||||||
<p>
|
<p>
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="number">1</span><span class="special">,</span><span class="number">3</span><span class="special">,</span><span class="number">5</span><span class="special">,</span><span class="number">7</span><span class="special">,</span><span class="number">9</span>
|
<pre class="programlisting"><span class="number">1</span><span class="special">,</span><span class="number">3</span><span class="special">,</span><span class="number">5</span><span class="special">,</span><span class="number">7</span><span class="special">,</span><span class="number">9</span><span class="special">,</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
<div class="titlepage"><div><div><h5 class="title">
|
<div class="titlepage"><div><div><h5 class="title">
|
||||||
<a name="range.reference.adaptors.reference.tokenized"></a><a class="link" href="tokenized.html" title="tokenized">tokenized</a>
|
<a name="range.reference.adaptors.reference.tokenized"></a><a class="link" href="tokenized.html" title="tokenized">tokenized</a>
|
||||||
</h5></div></div></div>
|
</h5></div></div></div>
|
||||||
|
<div class="toc"><dl><dt><span class="section"><a href="tokenized.html#range.reference.adaptors.reference.tokenized.tokenized_example">tokenized_example</a></span></dt></dl></div>
|
||||||
<div class="informaltable"><table class="table">
|
<div class="informaltable"><table class="table">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col>
|
<col>
|
||||||
@ -134,6 +135,50 @@
|
|||||||
Access Range</a>
|
Access Range</a>
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
|
<div class="section range_reference_adaptors_reference_tokenized_tokenized_example">
|
||||||
|
<div class="titlepage"><div><div><h6 class="title">
|
||||||
|
<a name="range.reference.adaptors.reference.tokenized.tokenized_example"></a><a class="link" href="tokenized.html#range.reference.adaptors.reference.tokenized.tokenized_example" title="tokenized_example">tokenized_example</a>
|
||||||
|
</h6></div></div></div>
|
||||||
|
<p>
|
||||||
|
</p>
|
||||||
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">tokenized</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||||
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iterator</span><span class="special">></span>
|
||||||
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
||||||
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
<span class="special">{</span>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">sub_match</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">::</span><span class="identifier">iterator</span> <span class="special">></span> <span class="identifier">match_type</span><span class="special">;</span>
|
||||||
|
|
||||||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">input</span> <span class="special">=</span> <span class="string">" a b c d e f g hijklmnopqrstuvwxyz"</span><span class="special">;</span>
|
||||||
|
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span>
|
||||||
|
<span class="identifier">input</span> <span class="special">|</span> <span class="identifier">tokenized</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">regex</span><span class="special">(</span><span class="string">"\\w+"</span><span class="special">)),</span>
|
||||||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream_iterator</span><span class="special"><</span><span class="identifier">match_type</span><span class="special">>(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">"\n"</span><span class="special">));</span>
|
||||||
|
|
||||||
|
<span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
|
||||||
|
<span class="special">}</span>
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<p>
|
||||||
|
This would produce the output:
|
||||||
|
</p>
|
||||||
|
<pre class="programlisting"><span class="identifier">a</span>
|
||||||
|
<span class="identifier">b</span>
|
||||||
|
<span class="identifier">c</span>
|
||||||
|
<span class="identifier">d</span>
|
||||||
|
<span class="identifier">e</span>
|
||||||
|
<span class="identifier">f</span>
|
||||||
|
<span class="identifier">g</span>
|
||||||
|
<span class="identifier">hijklmnopqrstuvwxyz</span>
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"></td>
|
<td align="left"></td>
|
||||||
|
@ -113,7 +113,7 @@
|
|||||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">transformed</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">transformed</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iterator</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
||||||
|
|
||||||
@ -144,7 +144,7 @@
|
|||||||
<p>
|
<p>
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="number">2</span><span class="special">,</span><span class="number">4</span><span class="special">,</span><span class="number">6</span><span class="special">,</span><span class="number">8</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">12</span><span class="special">,</span><span class="number">14</span><span class="special">,</span><span class="number">16</span><span class="special">,</span><span class="number">18</span><span class="special">,</span><span class="number">20</span>
|
<pre class="programlisting"><span class="number">2</span><span class="special">,</span><span class="number">4</span><span class="special">,</span><span class="number">6</span><span class="special">,</span><span class="number">8</span><span class="special">,</span><span class="number">10</span><span class="special">,</span><span class="number">12</span><span class="special">,</span><span class="number">14</span><span class="special">,</span><span class="number">16</span><span class="special">,</span><span class="number">18</span><span class="special">,</span><span class="number">20</span><span class="special">,</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
|
@ -190,7 +190,7 @@
|
|||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">foreach</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">foreach</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iterator</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">list</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">list</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
||||||
@ -279,10 +279,10 @@
|
|||||||
<p>
|
<p>
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
</p>
|
</p>
|
||||||
<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>
|
<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><span class="number">7</span><span class="special">,</span><span class="number">8</span><span class="special">,</span><span class="number">9</span><span class="special">,</span><span class="number">10</span>
|
<span class="number">6</span><span class="special">,</span><span class="number">7</span><span class="special">,</span><span class="number">8</span><span class="special">,</span><span class="number">9</span><span class="special">,</span><span class="number">10</span><span class="special">,</span>
|
||||||
<span class="number">11</span><span class="special">,</span><span class="number">12</span><span class="special">,</span><span class="number">13</span><span class="special">,</span><span class="number">14</span><span class="special">,</span><span class="number">15</span>
|
<span class="number">11</span><span class="special">,</span><span class="number">12</span><span class="special">,</span><span class="number">13</span><span class="special">,</span><span class="number">14</span><span class="special">,</span><span class="number">15</span><span class="special">,</span>
|
||||||
<span class="number">11</span><span class="special">,</span><span class="number">12</span><span class="special">,</span><span class="number">13</span><span class="special">,</span><span class="number">14</span><span class="special">,</span><span class="number">15</span>
|
<span class="number">11</span><span class="special">,</span><span class="number">12</span><span class="special">,</span><span class="number">13</span><span class="special">,</span><span class="number">14</span><span class="special">,</span><span class="number">15</span><span class="special">,</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
|
@ -105,11 +105,11 @@
|
|||||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</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">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iterator</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
|
||||||
|
|
||||||
<span class="keyword">void</span> <span class="identifier">uniqued_example_test</span><span class="special">()</span>
|
<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>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
<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>
|
<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>
|
||||||
<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>
|
<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>
|
||||||
@ -120,6 +120,8 @@
|
|||||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span>
|
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span>
|
||||||
<span class="identifier">input</span> <span class="special">|</span> <span class="identifier">uniqued</span><span class="special">,</span>
|
<span class="identifier">input</span> <span class="special">|</span> <span class="identifier">uniqued</span><span class="special">,</span>
|
||||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream_iterator</span><span class="special"><</span><span class="keyword">int</span><span class="special">>(</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>
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream_iterator</span><span class="special"><</span><span class="keyword">int</span><span class="special">>(</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>
|
||||||
|
|
||||||
|
<span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
|
||||||
<span class="special">}</span>
|
<span class="special">}</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
@ -128,7 +130,7 @@
|
|||||||
<p>
|
<p>
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
</p>
|
</p>
|
||||||
<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>
|
<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>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
|
@ -52,8 +52,8 @@
|
|||||||
</h6>
|
</h6>
|
||||||
<p>
|
<p>
|
||||||
<code class="computeroutput"><span class="identifier">pop_heap</span></code> removes the
|
<code class="computeroutput"><span class="identifier">pop_heap</span></code> removes the
|
||||||
largest element from the heap. It is assumed that <code class="computeroutput"><span class="identifier">begin</span><span class="special">(</span><span class="identifier">rng</span><span class="special">),</span> <span class="identifier">prior</span><span class="special">(</span><span class="identifier">end</span><span class="special">(</span><span class="identifier">rng</span><span class="special">))</span></code> is already a heap and that the element
|
largest element from the heap. It is assumed that <code class="computeroutput"><span class="identifier">begin</span><span class="special">(</span><span class="identifier">rng</span><span class="special">),</span> <span class="identifier">prior</span><span class="special">(</span><span class="identifier">end</span><span class="special">(</span><span class="identifier">rng</span><span class="special">))</span></code> is already a heap (and therefore the
|
||||||
to be added is <code class="computeroutput"><span class="special">*</span><span class="identifier">prior</span><span class="special">(</span><span class="identifier">end</span><span class="special">(</span><span class="identifier">rng</span><span class="special">))</span></code>.
|
largest element is <code class="computeroutput"><span class="special">*</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">rng</span><span class="special">)</span></code>).
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
The ordering relationship is determined by using <code class="computeroutput"><span class="keyword">operator</span><span class="special"><</span></code> in the non-predicate versions, and
|
The ordering relationship is determined by using <code class="computeroutput"><span class="keyword">operator</span><span class="special"><</span></code> in the non-predicate versions, and
|
||||||
|
@ -47,7 +47,8 @@
|
|||||||
<span class="identifier">Value</span> <span class="identifier">inner_product</span><span class="special">(</span> <span class="keyword">const</span> <span class="identifier">SinglePassRange1</span><span class="special">&</span> <span class="identifier">rng1</span><span class="special">,</span>
|
<span class="identifier">Value</span> <span class="identifier">inner_product</span><span class="special">(</span> <span class="keyword">const</span> <span class="identifier">SinglePassRange1</span><span class="special">&</span> <span class="identifier">rng1</span><span class="special">,</span>
|
||||||
<span class="keyword">const</span> <span class="identifier">SinglePassRange2</span><span class="special">&</span> <span class="identifier">rng2</span><span class="special">,</span>
|
<span class="keyword">const</span> <span class="identifier">SinglePassRange2</span><span class="special">&</span> <span class="identifier">rng2</span><span class="special">,</span>
|
||||||
<span class="identifier">Value</span> <span class="identifier">init</span><span class="special">,</span>
|
<span class="identifier">Value</span> <span class="identifier">init</span><span class="special">,</span>
|
||||||
<span class="identifier">BinaryOperation1</span> <span class="identifier">op1</span> <span class="special">);</span>
|
<span class="identifier">BinaryOperation1</span> <span class="identifier">op1</span><span class="special">,</span>
|
||||||
|
<span class="identifier">BinaryOperation2</span> <span class="identifier">op2</span> <span class="special">);</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
|
@ -81,6 +81,14 @@
|
|||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
<span class="keyword">return</span> <span class="identifier">reverse_range</span><span class="special"><</span><span class="keyword">const</span> <span class="identifier">BidirectionalRng</span><span class="special">>(</span> <span class="identifier">r</span> <span class="special">);</span>
|
<span class="keyword">return</span> <span class="identifier">reverse_range</span><span class="special"><</span><span class="keyword">const</span> <span class="identifier">BidirectionalRng</span><span class="special">>(</span> <span class="identifier">r</span> <span class="special">);</span>
|
||||||
<span class="special">}</span>
|
<span class="special">}</span>
|
||||||
|
</pre>
|
||||||
|
</li>
|
||||||
|
<li class="listitem">
|
||||||
|
Declare the adaptor itself (it is a variable of the tag type).
|
||||||
|
<pre class="programlisting"><span class="keyword">namespace</span>
|
||||||
|
<span class="special">{</span>
|
||||||
|
<span class="keyword">const</span> <span class="identifier">detail</span><span class="special">::</span><span class="identifier">reverse_forwarder</span> <span class="identifier">reversed</span> <span class="special">=</span> <span class="identifier">detail</span><span class="special">::</span><span class="identifier">reverse_forwarder</span><span class="special">();</span>
|
||||||
|
<span class="special">}</span>
|
||||||
</pre>
|
</pre>
|
||||||
</li>
|
</li>
|
||||||
</ol></div>
|
</ol></div>
|
||||||
|
@ -80,15 +80,8 @@
|
|||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
Implement a holder class to hold the arguments required to construct
|
Implement a holder class to hold the arguments required to construct
|
||||||
the RangeAdaptor.
|
the RangeAdaptor. The holder combines multiple parameters into one
|
||||||
</li>
|
that can be passed as the right operand of <code class="computeroutput"><span class="keyword">operator</span><span class="special">|()</span></code>.
|
||||||
</ol></div>
|
|
||||||
<p>
|
|
||||||
The holder combines multiple parameters into one that can be passed as
|
|
||||||
the right operand of <code class="computeroutput"><span class="keyword">operator</span><span class="special">|()</span></code>.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
|
||||||
<span class="keyword">class</span> <span class="identifier">replace_holder</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_detail</span><span class="special">::</span><span class="identifier">holder2</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span>
|
<span class="keyword">class</span> <span class="identifier">replace_holder</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_detail</span><span class="special">::</span><span class="identifier">holder2</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
@ -100,23 +93,15 @@
|
|||||||
<span class="keyword">void</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">replace_holder</span><span class="special">&);</span>
|
<span class="keyword">void</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">replace_holder</span><span class="special">&);</span>
|
||||||
<span class="special">};</span>
|
<span class="special">};</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
</li>
|
||||||
</p>
|
<li class="listitem">
|
||||||
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
|
|
||||||
Define an instance of the holder with the name of the adaptor
|
Define an instance of the holder with the name of the adaptor
|
||||||
</li></ol></div>
|
|
||||||
<p>
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_detail</span><span class="special">::</span><span class="identifier">forwarder2</span><span class="special"><</span><span class="identifier">replace_holder</span><span class="special">></span>
|
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_detail</span><span class="special">::</span><span class="identifier">forwarder2</span><span class="special"><</span><span class="identifier">replace_holder</span><span class="special">></span>
|
||||||
<span class="identifier">replaced</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_detail</span><span class="special">::</span><span class="identifier">forwarder2</span><span class="special"><</span><span class="identifier">replace_holder</span><span class="special">>();</span>
|
<span class="identifier">replaced</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_detail</span><span class="special">::</span><span class="identifier">forwarder2</span><span class="special"><</span><span class="identifier">replace_holder</span><span class="special">>();</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
</li>
|
||||||
</p>
|
<li class="listitem">
|
||||||
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
|
|
||||||
Define <code class="computeroutput"><span class="keyword">operator</span><span class="special">|</span></code>
|
Define <code class="computeroutput"><span class="keyword">operator</span><span class="special">|</span></code>
|
||||||
</li></ol></div>
|
|
||||||
<p>
|
|
||||||
</p>
|
|
||||||
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">SinglePassRange</span><span class="special">></span>
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">SinglePassRange</span><span class="special">></span>
|
||||||
<span class="keyword">inline</span> <span class="identifier">replace_range</span><span class="special"><</span><span class="identifier">SinglePassRange</span><span class="special">></span>
|
<span class="keyword">inline</span> <span class="identifier">replace_range</span><span class="special"><</span><span class="identifier">SinglePassRange</span><span class="special">></span>
|
||||||
<span class="keyword">operator</span><span class="special">|(</span><span class="identifier">SinglePassRange</span><span class="special">&</span> <span class="identifier">rng</span><span class="special">,</span>
|
<span class="keyword">operator</span><span class="special">|(</span><span class="identifier">SinglePassRange</span><span class="special">&</span> <span class="identifier">rng</span><span class="special">,</span>
|
||||||
@ -133,8 +118,8 @@
|
|||||||
<span class="keyword">return</span> <span class="identifier">replace_range</span><span class="special"><</span><span class="keyword">const</span> <span class="identifier">SinglePassRange</span><span class="special">>(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">f</span><span class="special">.</span><span class="identifier">val1</span><span class="special">,</span> <span class="identifier">f</span><span class="special">.</span><span class="identifier">val2</span><span class="special">);</span>
|
<span class="keyword">return</span> <span class="identifier">replace_range</span><span class="special"><</span><span class="keyword">const</span> <span class="identifier">SinglePassRange</span><span class="special">>(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">f</span><span class="special">.</span><span class="identifier">val1</span><span class="special">,</span> <span class="identifier">f</span><span class="special">.</span><span class="identifier">val2</span><span class="special">);</span>
|
||||||
<span class="special">}</span>
|
<span class="special">}</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
</li>
|
||||||
</p>
|
</ol></div>
|
||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"></td>
|
<td align="left"></td>
|
||||||
|
@ -93,7 +93,7 @@ What this means is that ['*no*] algorithm with the `_if` suffix is needed. Furth
|
|||||||
|
|
||||||
``
|
``
|
||||||
std::vector<int> vec;
|
std::vector<int> vec;
|
||||||
boost::replace_copy_if( rng, std::back_inserter(vec), pred );
|
boost::replace_copy_if( rng, std::back_inserter(vec), pred, new_value );
|
||||||
``
|
``
|
||||||
|
|
||||||
With adaptors and algorithms we can express this as
|
With adaptors and algorithms we can express this as
|
||||||
|
@ -19,35 +19,13 @@
|
|||||||
* [*Returned Range Category:] The minimum of the range category of `rng` and __forward_range__
|
* [*Returned Range Category:] The minimum of the range category of `rng` and __forward_range__
|
||||||
|
|
||||||
[section:adjacent_filtered_example adjacent_filtered example]
|
[section:adjacent_filtered_example adjacent_filtered example]
|
||||||
``
|
[import ../../../test/adaptor_test/adjacent_filtered_example.cpp]
|
||||||
#include <boost/range/adaptor/adjacent_filtered.hpp>
|
[adjacent_filtered_example]
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <functional>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,1,2,2,2,3,4,5,6;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | adjacent_filtered(std::not_equal_to<int>()),
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
``
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
``
|
``
|
||||||
1,2,3,4,5,6
|
1,2,3,4,5,6,
|
||||||
``
|
``
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@ -17,34 +17,13 @@
|
|||||||
* [*Returned Range Category:] __random_access_range__
|
* [*Returned Range Category:] __random_access_range__
|
||||||
|
|
||||||
[section:copied_example copied example]
|
[section:copied_example copied example]
|
||||||
``
|
[import ../../../test/adaptor_test/copied_example.cpp]
|
||||||
#include <boost/range/adaptor/copied.hpp>
|
[copied_example]
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,2,3,4,5,6,7,8,9,10;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | copied(1, 5),
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
``
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
``
|
``
|
||||||
2,3,4,5
|
2,3,4,5,
|
||||||
``
|
``
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
// Boost.Range library
|
|
||||||
//
|
|
||||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
|
||||||
// distribution is subject to the Boost Software License, Version
|
|
||||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
|
||||||
//
|
|
||||||
#include <boost/range/adaptor/adjacent_filtered.hpp>
|
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <functional>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,1,2,2,2,3,4,5,6;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | adjacent_filtered(std::not_equal_to<int>()),
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
|||||||
// Boost.Range library
|
|
||||||
//
|
|
||||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
|
||||||
// distribution is subject to the Boost Software License, Version
|
|
||||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
|
||||||
//
|
|
||||||
#include <boost/range/adaptor/copied.hpp>
|
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,2,3,4,5,6,7,8,9,10;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | copied(1, 5),
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
|||||||
// Boost.Range library
|
|
||||||
//
|
|
||||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
|
||||||
// distribution is subject to the Boost Software License, Version
|
|
||||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
|
||||||
//
|
|
||||||
#include <boost/range/adaptor/filtered.hpp>
|
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
struct is_even
|
|
||||||
{
|
|
||||||
bool operator()(int x) const { return x % 2 == 0; }
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,2,3,4,5,6,7,8,9;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | filtered(is_even()),
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
|||||||
// Boost.Range library
|
|
||||||
//
|
|
||||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
|
||||||
// distribution is subject to the Boost Software License, Version
|
|
||||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
|
||||||
//
|
|
||||||
#include <boost/range/adaptor/indexed.hpp>
|
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
template<typename Iterator>
|
|
||||||
void display_element_and_index(Iterator first, Iterator last)
|
|
||||||
{
|
|
||||||
for (Iterator it = first; it != last; ++it)
|
|
||||||
{
|
|
||||||
std::cout << "Element = " << *it
|
|
||||||
<< " Index = " << it.index() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename SinglePassRange>
|
|
||||||
void display_element_and_index(const SinglePassRange& rng)
|
|
||||||
{
|
|
||||||
display_element_and_index(boost::begin(rng), boost::end(rng));
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 10,20,30,40,50,60,70,80,90;
|
|
||||||
|
|
||||||
display_element_and_index( input | indexed(0) );
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
|||||||
// Boost.Range library
|
|
||||||
//
|
|
||||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
|
||||||
// distribution is subject to the Boost Software License, Version
|
|
||||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
|
||||||
//
|
|
||||||
#include <boost/range/adaptor/map.hpp>
|
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
|
|
||||||
std::map<int, int> input;
|
|
||||||
for (int i = 0; i < 10; ++i)
|
|
||||||
input.insert(std::make_pair(i, i * 10));
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | map_keys,
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
|||||||
// Boost.Range library
|
|
||||||
//
|
|
||||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
|
||||||
// distribution is subject to the Boost Software License, Version
|
|
||||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
|
||||||
//
|
|
||||||
#include <boost/range/adaptor/map.hpp>
|
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
|
|
||||||
std::map<int, int> input;
|
|
||||||
for (int i = 0; i < 10; ++i)
|
|
||||||
input.insert(std::make_pair(i, i * 10));
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | map_values,
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
|||||||
// Boost.Range library
|
|
||||||
//
|
|
||||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
|
||||||
// distribution is subject to the Boost Software License, Version
|
|
||||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
|
||||||
//
|
|
||||||
#include <boost/range/adaptor/replaced.hpp>
|
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
using namespace boost::assign;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,2,3,2,5,2,7,2,9;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | replaced(2, 10),
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
|||||||
// Boost.Range library
|
|
||||||
//
|
|
||||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
|
||||||
// distribution is subject to the Boost Software License, Version
|
|
||||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
|
||||||
//
|
|
||||||
#include <boost/range/adaptor/replaced_if.hpp>
|
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
struct is_even
|
|
||||||
{
|
|
||||||
bool operator()(int x) const { return x % 2 == 0; }
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
using namespace boost::assign;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,2,3,4,5,6,7,8,9;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | replaced_if(is_even(), 10),
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
// Boost.Range library
|
|
||||||
//
|
|
||||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
|
||||||
// distribution is subject to the Boost Software License, Version
|
|
||||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
|
||||||
//
|
|
||||||
#include <boost/range/adaptor/reversed.hpp>
|
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
using namespace boost::assign;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,2,3,4,5,6,7,8,9;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | reversed,
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
|||||||
// Boost.Range library
|
|
||||||
//
|
|
||||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
|
||||||
// distribution is subject to the Boost Software License, Version
|
|
||||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
|
||||||
//
|
|
||||||
#include <boost/range/adaptor/sliced.hpp>
|
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
using namespace boost::assign;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,2,3,4,5,6,7,8,9;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | sliced(2, 5),
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
|||||||
// Boost.Range library
|
|
||||||
//
|
|
||||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
|
||||||
// distribution is subject to the Boost Software License, Version
|
|
||||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
|
||||||
//
|
|
||||||
#include <boost/range/adaptor/strided.hpp>
|
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
using namespace boost::assign;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,2,3,4,5,6,7,8,9,10;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | strided(2),
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
|||||||
// Boost.Range library
|
|
||||||
//
|
|
||||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
|
||||||
// distribution is subject to the Boost Software License, Version
|
|
||||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
|
||||||
//
|
|
||||||
#include <boost/range/adaptor/tokenized.hpp>
|
|
||||||
#include <boost/range/algorithm_ext/push_back.hpp>
|
|
||||||
#include <boost/assert.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
|
|
||||||
std::string input = " a b c d e f g hijklmnopqrstuvwxyz";
|
|
||||||
std::vector< boost::sub_match< std::string::iterator > > result;
|
|
||||||
boost::push_back(result, input | tokenized(boost::regex("\\b")));
|
|
||||||
|
|
||||||
BOOST_ASSERT( boost::size(result) == 16u );
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
// Boost.Range library
|
|
||||||
//
|
|
||||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
|
||||||
// distribution is subject to the Boost Software License, Version
|
|
||||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
|
||||||
//
|
|
||||||
#include <boost/range/adaptor/transformed.hpp>
|
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
struct double_int
|
|
||||||
{
|
|
||||||
typedef int result_type;
|
|
||||||
int operator()(int x) const { return x * 2; }
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
using namespace boost::assign;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,2,3,4,5,6,7,8,9,10;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | transformed(double_int()),
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
|||||||
// Boost.Range library
|
|
||||||
//
|
|
||||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
|
||||||
// distribution is subject to the Boost Software License, Version
|
|
||||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
|
||||||
//
|
|
||||||
#include <boost/range/adaptor/uniqued.hpp>
|
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,1,2,2,2,3,4,5,6;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | uniqued,
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -19,37 +19,13 @@
|
|||||||
* [*Returned Range Category:] The minimum of the range category of `rng` and __bidirectional_range__
|
* [*Returned Range Category:] The minimum of the range category of `rng` and __bidirectional_range__
|
||||||
|
|
||||||
[section:filtered_example filtered example]
|
[section:filtered_example filtered example]
|
||||||
``
|
[import ../../../test/adaptor_test/filtered_example.cpp]
|
||||||
#include <boost/range/adaptor/filtered.hpp>
|
[filtered_example]
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
struct is_even
|
|
||||||
{
|
|
||||||
bool operator()( int x ) const { return x % 2 == 0; }
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,2,3,4,5,6,7,8,9;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | filtered(is_even()),
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
}
|
|
||||||
``
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
``
|
``
|
||||||
2,4,6,8
|
2,4,6,8,
|
||||||
``
|
``
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
[table
|
[table
|
||||||
[[Syntax] [Code]]
|
[[Syntax] [Code]]
|
||||||
[[Pipe] [`rng | boost::adaptors::indexed`]]
|
[[Pipe] [`rng | boost::adaptors::indexed(start_index)`]]
|
||||||
[[Function] [`boost::adaptors::index(rng)`]]
|
[[Function] [`boost::adaptors::index(rng, start_index)`]]
|
||||||
]
|
]
|
||||||
|
|
||||||
* [*Returns:] A range adapted to return both the element and the associated index. The returned range consists of iterators that have in addition to the usual iterator member functions an `index()` member function that returns the appropriate index for the element in the sequence corresponding with the iterator.
|
* [*Returns:] A range adapted to return both the element and the associated index. The returned range consists of iterators that have in addition to the usual iterator member functions an `index()` member function that returns the appropriate index for the element in the sequence corresponding with the iterator.
|
||||||
@ -17,63 +17,8 @@
|
|||||||
* [*Returned Range Category:] The range category of `rng`
|
* [*Returned Range Category:] The range category of `rng`
|
||||||
|
|
||||||
[section:indexed_example indexed example]
|
[section:indexed_example indexed example]
|
||||||
``
|
[import ../../../test/adaptor_test/indexed_example.cpp]
|
||||||
#include <boost/range/adaptor/indexed.hpp>
|
[indexed_example]
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
template<class Iterator>
|
|
||||||
void display_element_and_index(Iterator first, Iterator last)
|
|
||||||
{
|
|
||||||
for (Iterator it = first; it != last; ++it)
|
|
||||||
{
|
|
||||||
std::cout << "Element = " << *it << " Index = " << it.index() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class SinglePassRange>
|
|
||||||
void display_element_and_index(const SinglePassRange& rng)
|
|
||||||
{
|
|
||||||
display_element_and_index(boost::begin(rng), boost::end(rng));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Iterator1, class Iterator2>
|
|
||||||
void check_element_and_index(
|
|
||||||
Iterator1 test_first,
|
|
||||||
Iterator1 test_last,
|
|
||||||
Iterator2 reference_first,
|
|
||||||
Iterator2 reference_last)
|
|
||||||
{
|
|
||||||
BOOST_CHECK_EQUAL( std::distance(test_first, test_last),
|
|
||||||
std::distance(reference_first, reference_last) );
|
|
||||||
|
|
||||||
int reference_index = 0;
|
|
||||||
|
|
||||||
Iterator1 test_it = test_first;
|
|
||||||
Iterator2 reference_it = reference_first;
|
|
||||||
for (; test_it != test_last; ++test_it, ++reference_it, ++reference_index)
|
|
||||||
{
|
|
||||||
BOOST_CHECK_EQUAL( *test_it, *reference_it );
|
|
||||||
BOOST_CHECK_EQUAL( test_it.index(), reference_index );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 10,20,30,40,50,60,70,80,90;
|
|
||||||
|
|
||||||
display_element_and_index( input | indexed(0) );
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
``
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
|
@ -18,35 +18,13 @@
|
|||||||
* [*Returned Range Category:] The range category of `rng`
|
* [*Returned Range Category:] The range category of `rng`
|
||||||
|
|
||||||
[section:indirected_example indirected example]
|
[section:indirected_example indirected example]
|
||||||
``
|
[import ../../../test/adaptor_test/indirected_example.cpp]
|
||||||
#include <boost/range/adaptor/indirected.hpp>
|
[indirected_example]
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
|
|
||||||
std::vector<boost::shared_ptr<int> > input;
|
|
||||||
|
|
||||||
for (int i = 0; i < 10; ++i)
|
|
||||||
input.push_back(boost::shared_ptr<int>(new int(i)));
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | indirected,
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
``
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
``
|
``
|
||||||
0,1,2,3,4,5,6,7,8,9
|
0,1,2,3,4,5,6,7,8,9,
|
||||||
``
|
``
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@ -18,36 +18,13 @@
|
|||||||
* [*Returned Range Category:] The range category of `rng`.
|
* [*Returned Range Category:] The range category of `rng`.
|
||||||
|
|
||||||
[section:map_keys_example map_keys example]
|
[section:map_keys_example map_keys example]
|
||||||
``
|
[import ../../../test/adaptor_test/map_keys_example.cpp]
|
||||||
#include <boost/range/adaptor/map.hpp>
|
[map_keys_example]
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
|
|
||||||
std::map<int,int> input;
|
|
||||||
for (int i = 0; i < 10; ++i)
|
|
||||||
input.insert(std::make_pair(i, i * 10));
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | map_keys,
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
``
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
``
|
``
|
||||||
0,1,2,3,4,5,6,7,8,9
|
0,1,2,3,4,5,6,7,8,9,
|
||||||
``
|
``
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@ -18,36 +18,13 @@
|
|||||||
* [*Returned Range Category:] The range category of `rng`.
|
* [*Returned Range Category:] The range category of `rng`.
|
||||||
|
|
||||||
[section:map_values_example map_values example]
|
[section:map_values_example map_values example]
|
||||||
``
|
[import ../../../test/adaptor_test/map_values_example.cpp]
|
||||||
#include <boost/range/adaptor/map.hpp>
|
[map_values_example]
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
|
|
||||||
std::map<int,int> input;
|
|
||||||
for (int i = 0; i < 10; ++i)
|
|
||||||
input.insert(std::make_pair(i, i * 10));
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | map_values,
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
``
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
``
|
``
|
||||||
0,10,20,30,40,50,60,70,80,90
|
0,10,20,30,40,50,60,70,80,90,
|
||||||
``
|
``
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@ -20,34 +20,13 @@
|
|||||||
* [*Returned Range Category:] The range category of `rng`.
|
* [*Returned Range Category:] The range category of `rng`.
|
||||||
|
|
||||||
[section:replaced_example replaced example]
|
[section:replaced_example replaced example]
|
||||||
``
|
[import ../../../test/adaptor_test/replaced_example.cpp]
|
||||||
#include <boost/range/adaptor/replaced.hpp>
|
[replaced_example]
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
using namespace boost::assign;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,2,3,2,5,2,7,2,9;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | replaced(2, 10),
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
``
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
``
|
``
|
||||||
1,10,3,10,5,10,7,10,9
|
1,10,3,10,5,10,7,10,9,
|
||||||
``
|
``
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@ -20,39 +20,13 @@
|
|||||||
* [*Returned Range Category:] The range category of `rng`.
|
* [*Returned Range Category:] The range category of `rng`.
|
||||||
|
|
||||||
[section:replaced_if_example replaced_if example]
|
[section:replaced_if_example replaced_if example]
|
||||||
``
|
[import ../../../test/adaptor_test/replaced_if_example.cpp]
|
||||||
#include <boost/range/adaptor/replaced_if.hpp>
|
[replaced_if_example]
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
struct is_even
|
|
||||||
{
|
|
||||||
bool operator()(int x) const { return x % 2 == 0; }
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
using namespace boost::assign;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,2,3,4,5,6,7,8,9;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | replaced_if(is_even(), 10),
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
``
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
``
|
``
|
||||||
1,10,3,10,5,10,7,10,9
|
1,10,3,10,5,10,7,10,9,
|
||||||
``
|
``
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@ -17,34 +17,13 @@
|
|||||||
* [*Returned Range Category:] The range category of `rng`.
|
* [*Returned Range Category:] The range category of `rng`.
|
||||||
|
|
||||||
[section:reversed_example reversed example]
|
[section:reversed_example reversed example]
|
||||||
``
|
[import ../../../test/adaptor_test/reversed_example.cpp]
|
||||||
#include <boost/range/adaptor/reversed.hpp>
|
[reversed_example]
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
void reversed_example_test()
|
|
||||||
{
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
using namespace boost::assign;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,2,3,4,5,6,7,8,9;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | reversed,
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
``
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
``
|
``
|
||||||
9,8,7,6,5,4,3,2,1
|
9,8,7,6,5,4,3,2,1,
|
||||||
``
|
``
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@ -18,34 +18,13 @@
|
|||||||
* [*Returned Range Category:] __random_access_range__
|
* [*Returned Range Category:] __random_access_range__
|
||||||
|
|
||||||
[section:sliced_example sliced example]
|
[section:sliced_example sliced example]
|
||||||
``
|
[import ../../../test/adaptor_test/sliced_example.cpp]
|
||||||
#include <boost/range/adaptor/sliced.hpp>
|
[sliced_example]
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
using namespace boost::assign;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,2,3,4,5,6,7,8,9;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | sliced(2, 5),
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
``
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
``
|
``
|
||||||
3,4,5
|
3,4,5,
|
||||||
``
|
``
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@ -17,34 +17,13 @@
|
|||||||
* [*Returned Range Category:] The range category of `rng`.
|
* [*Returned Range Category:] The range category of `rng`.
|
||||||
|
|
||||||
[section:strided_example strided example]
|
[section:strided_example strided example]
|
||||||
``
|
[import ../../../test/adaptor_test/strided_example.cpp]
|
||||||
#include <boost/range/adaptor/strided.hpp>
|
[strided_example]
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
using namespace boost::assign;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,2,3,4,5,6,7,8,9,10;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | strided(2),
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
``
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
``
|
``
|
||||||
1,3,5,7,9
|
1,3,5,7,9,
|
||||||
``
|
``
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@ -44,6 +44,24 @@
|
|||||||
* [*Range Return Type:] `boost::tokenized_range<typeof(rng)>`
|
* [*Range Return Type:] `boost::tokenized_range<typeof(rng)>`
|
||||||
* [*Returned Range Category:] __random_access_range__
|
* [*Returned Range Category:] __random_access_range__
|
||||||
|
|
||||||
|
[section:tokenized_example tokenized_example]
|
||||||
|
[import ../../../test/adaptor_test/tokenized_example.cpp]
|
||||||
|
[tokenized_example]
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
This would produce the output:
|
||||||
|
``
|
||||||
|
a
|
||||||
|
b
|
||||||
|
c
|
||||||
|
d
|
||||||
|
e
|
||||||
|
f
|
||||||
|
g
|
||||||
|
hijklmnopqrstuvwxyz
|
||||||
|
|
||||||
|
``
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,40 +19,13 @@
|
|||||||
* [*Returned Range Category:] The range category of `rng`.
|
* [*Returned Range Category:] The range category of `rng`.
|
||||||
|
|
||||||
[section:transformed_example transformed example]
|
[section:transformed_example transformed example]
|
||||||
``
|
[import ../../../test/adaptor_test/transformed_example.cpp]
|
||||||
#include <boost/range/adaptor/transformed.hpp>
|
[transformed_example]
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
struct double_int
|
|
||||||
{
|
|
||||||
typedef int result_type;
|
|
||||||
int operator()(int x) const { return x * 2; }
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
using namespace boost::assign;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,2,3,4,5,6,7,8,9,10;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | transformed(double_int()),
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
``
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
``
|
``
|
||||||
2,4,6,8,10,12,14,16,18,20
|
2,4,6,8,10,12,14,16,18,20,
|
||||||
``
|
``
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@ -49,102 +49,16 @@ public:
|
|||||||
``
|
``
|
||||||
|
|
||||||
[section:type_erased_example type-erased example]
|
[section:type_erased_example type-erased example]
|
||||||
``
|
[import ../../../test/adaptor_test/type_erased_example.cpp]
|
||||||
#include <boost/range/adaptor/type_erased.hpp>
|
[type_erased_example]
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <list>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
// The client interface from an OO perspective merely requires a sequence
|
|
||||||
// of integers that can be forward traversed
|
|
||||||
typedef boost::any_range<
|
|
||||||
int
|
|
||||||
, boost::forward_traversal_tag
|
|
||||||
, int
|
|
||||||
, std::ptrdiff_t
|
|
||||||
> integer_range;
|
|
||||||
|
|
||||||
namespace server
|
|
||||||
{
|
|
||||||
void display_integers(const integer_range& rng)
|
|
||||||
{
|
|
||||||
boost::copy(rng,
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
|
|
||||||
std::cout << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace client
|
|
||||||
{
|
|
||||||
void run()
|
|
||||||
{
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
|
|
||||||
// Under most conditions one would simply use an appropriate
|
|
||||||
// any_range as a function parameter. The type_erased adaptor
|
|
||||||
// is often superfluous. However because the type_erased
|
|
||||||
// adaptor is applied to a range, we can use default template
|
|
||||||
// arguments that are generated in conjunction with the
|
|
||||||
// range type to which we are applying the adaptor.
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,2,3,4,5;
|
|
||||||
|
|
||||||
// Note that this call is to a non-template function
|
|
||||||
server::display_integers(input);
|
|
||||||
|
|
||||||
std::list<int> input2;
|
|
||||||
input2 += 6,7,8,9,10;
|
|
||||||
|
|
||||||
// Note that this call is to the same non-tempate function
|
|
||||||
server::display_integers(input2);
|
|
||||||
|
|
||||||
input2.clear();
|
|
||||||
input2 += 11,12,13,14,15;
|
|
||||||
|
|
||||||
// Calling using the adaptor looks like this:
|
|
||||||
// Notice that here I have a type_erased that would be a
|
|
||||||
// bidirectional_traversal_tag, but this is convertible
|
|
||||||
// to the forward_traversal_tag equivalent hence this
|
|
||||||
// works.
|
|
||||||
server::display_integers(input2 | type_erased<>());
|
|
||||||
|
|
||||||
// However we may simply wish to define an adaptor that
|
|
||||||
// takes a range and makes it into an appropriate
|
|
||||||
// forward_traversal any_range...
|
|
||||||
typedef boost::adaptors::type_erased<
|
|
||||||
boost::use_default
|
|
||||||
, boost::forward_traversal_tag
|
|
||||||
> type_erased_forward;
|
|
||||||
|
|
||||||
// This adaptor can turn other containers with different
|
|
||||||
// value_types and reference_types into the appropriate
|
|
||||||
// any_range.
|
|
||||||
|
|
||||||
server::display_integers(input2 | type_erased_forward());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
|
||||||
{
|
|
||||||
client::run();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
``
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
``
|
``
|
||||||
1,2,3,4,5
|
1,2,3,4,5,
|
||||||
6,7,8,9,10
|
6,7,8,9,10,
|
||||||
11,12,13,14,15
|
11,12,13,14,15,
|
||||||
11,12,13,14,15
|
11,12,13,14,15,
|
||||||
``
|
``
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@ -18,32 +18,13 @@
|
|||||||
* [*Returned Range Category:] The minimum of the range concept of `rng` and __forward_range__.
|
* [*Returned Range Category:] The minimum of the range concept of `rng` and __forward_range__.
|
||||||
|
|
||||||
[section:uniqued_example uniqued example]
|
[section:uniqued_example uniqued example]
|
||||||
``
|
[import ../../../test/adaptor_test/uniqued_example.cpp]
|
||||||
#include <boost/range/adaptor/uniqued.hpp>
|
[uniqued_example]
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
|
||||||
#include <boost/assign.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
void uniqued_example_test()
|
|
||||||
{
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace boost::adaptors;
|
|
||||||
|
|
||||||
std::vector<int> input;
|
|
||||||
input += 1,1,2,2,2,3,4,5,6;
|
|
||||||
|
|
||||||
boost::copy(
|
|
||||||
input | uniqued,
|
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
|
||||||
}
|
|
||||||
``
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
This would produce the output:
|
This would produce the output:
|
||||||
``
|
``
|
||||||
1,2,3,4,5,6
|
1,2,3,4,5,6,
|
||||||
``
|
``
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ const RandomAccessRange& pop_heap(const RandomAccessRange& rng, Compare pred);
|
|||||||
|
|
||||||
[heading Description]
|
[heading Description]
|
||||||
|
|
||||||
`pop_heap` removes the largest element from the heap. It is assumed that `begin(rng), prior(end(rng))` is already a heap and that the element to be added is `*prior(end(rng))`.
|
`pop_heap` removes the largest element from the heap. It is assumed that `begin(rng), prior(end(rng))` is already a heap (and therefore the largest element is `*begin(rng)`).
|
||||||
|
|
||||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||||
|
|
||||||
|
@ -218,6 +218,14 @@ operator|( const BidirectionalRng& r, detail::reverse_forwarder )
|
|||||||
}
|
}
|
||||||
``
|
``
|
||||||
|
|
||||||
|
# Declare the adaptor itself (it is a variable of the tag type).
|
||||||
|
``
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const detail::reverse_forwarder reversed = detail::reverse_forwarder();
|
||||||
|
}
|
||||||
|
``
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
[section:method_3_2 Method 3.2: Implement a Range Adaptor with arguments]
|
[section:method_3_2 Method 3.2: Implement a Range Adaptor with arguments]
|
||||||
@ -273,9 +281,7 @@ public:
|
|||||||
``
|
``
|
||||||
|
|
||||||
# Implement a holder class to hold the arguments required to construct the RangeAdaptor.
|
# Implement a holder class to hold the arguments required to construct the RangeAdaptor.
|
||||||
|
|
||||||
The holder combines multiple parameters into one that can be passed as the right operand of `operator|()`.
|
The holder combines multiple parameters into one that can be passed as the right operand of `operator|()`.
|
||||||
|
|
||||||
``
|
``
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class replace_holder : public boost::range_detail::holder2<T>
|
class replace_holder : public boost::range_detail::holder2<T>
|
||||||
@ -290,14 +296,12 @@ private:
|
|||||||
``
|
``
|
||||||
|
|
||||||
# Define an instance of the holder with the name of the adaptor
|
# Define an instance of the holder with the name of the adaptor
|
||||||
|
|
||||||
``
|
``
|
||||||
static boost::range_detail::forwarder2<replace_holder>
|
static boost::range_detail::forwarder2<replace_holder>
|
||||||
replaced = boost::range_detail::forwarder2<replace_holder>();
|
replaced = boost::range_detail::forwarder2<replace_holder>();
|
||||||
``
|
``
|
||||||
|
|
||||||
# Define `operator|`
|
# Define `operator|`
|
||||||
|
|
||||||
``
|
``
|
||||||
template<typename SinglePassRange>
|
template<typename SinglePassRange>
|
||||||
inline replace_range<SinglePassRange>
|
inline replace_range<SinglePassRange>
|
||||||
|
@ -23,7 +23,8 @@ template<class SinglePassRange1,
|
|||||||
Value inner_product( const SinglePassRange1& rng1,
|
Value inner_product( const SinglePassRange1& rng1,
|
||||||
const SinglePassRange2& rng2,
|
const SinglePassRange2& rng2,
|
||||||
Value init,
|
Value init,
|
||||||
BinaryOperation1 op1 );
|
BinaryOperation1 op1,
|
||||||
|
BinaryOperation2 op2 );
|
||||||
``
|
``
|
||||||
|
|
||||||
[heading Description]
|
[heading Description]
|
||||||
|
@ -31,21 +31,6 @@ rule range-test ( name : includes * )
|
|||||||
}
|
}
|
||||||
|
|
||||||
test-suite range :
|
test-suite range :
|
||||||
[ compile ../doc/reference/adaptors/examples/adjacent_filtered.cpp : : example_adjacent_filtered ]
|
|
||||||
[ compile ../doc/reference/adaptors/examples/copied.cpp : : example_copied ]
|
|
||||||
[ compile ../doc/reference/adaptors/examples/filtered.cpp : : example_filtered ]
|
|
||||||
[ compile ../doc/reference/adaptors/examples/indexed.cpp : : example_indexed ]
|
|
||||||
[ compile ../doc/reference/adaptors/examples/indirected.cpp : : example_indirected ]
|
|
||||||
[ compile ../doc/reference/adaptors/examples/map_keys.cpp : : example_map_keys ]
|
|
||||||
[ compile ../doc/reference/adaptors/examples/map_values.cpp : : example_map_values ]
|
|
||||||
[ compile ../doc/reference/adaptors/examples/replaced.cpp : : example_replaced ]
|
|
||||||
[ compile ../doc/reference/adaptors/examples/replaced_if.cpp : : example_replaced_if ]
|
|
||||||
[ compile ../doc/reference/adaptors/examples/reversed.cpp : : example_reversed ]
|
|
||||||
[ compile ../doc/reference/adaptors/examples/sliced.cpp : : example_sliced ]
|
|
||||||
[ compile ../doc/reference/adaptors/examples/strided.cpp : : example_strided ]
|
|
||||||
[ compile ../doc/reference/adaptors/examples/tokenized.cpp : : example_tokenized ]
|
|
||||||
[ compile ../doc/reference/adaptors/examples/transformed.cpp : : example_transformed ]
|
|
||||||
[ compile ../doc/reference/adaptors/examples/uniqued.cpp : : example_uniqued ]
|
|
||||||
[ compile-fail compile_fail/iterator_range1.cpp ]
|
[ compile-fail compile_fail/iterator_range1.cpp ]
|
||||||
[ range-test adaptor_test/adjacent_filtered ]
|
[ range-test adaptor_test/adjacent_filtered ]
|
||||||
[ range-test adaptor_test/copied ]
|
[ range-test adaptor_test/copied ]
|
||||||
@ -61,6 +46,7 @@ test-suite range :
|
|||||||
[ range-test adaptor_test/strided2 ]
|
[ range-test adaptor_test/strided2 ]
|
||||||
[ range-test adaptor_test/tokenized ]
|
[ range-test adaptor_test/tokenized ]
|
||||||
[ range-test adaptor_test/transformed ]
|
[ range-test adaptor_test/transformed ]
|
||||||
|
[ range-test adaptor_test/type_erased ]
|
||||||
[ range-test adaptor_test/uniqued ]
|
[ range-test adaptor_test/uniqued ]
|
||||||
[ range-test adaptor_test/adjacent_filtered_example ]
|
[ range-test adaptor_test/adjacent_filtered_example ]
|
||||||
[ range-test adaptor_test/copied_example ]
|
[ range-test adaptor_test/copied_example ]
|
||||||
@ -75,7 +61,7 @@ test-suite range :
|
|||||||
[ range-test adaptor_test/sliced_example ]
|
[ range-test adaptor_test/sliced_example ]
|
||||||
[ range-test adaptor_test/strided_example ]
|
[ range-test adaptor_test/strided_example ]
|
||||||
[ range-test adaptor_test/transformed_example ]
|
[ range-test adaptor_test/transformed_example ]
|
||||||
[ range-test adaptor_test/type_erased ]
|
[ range-test adaptor_test/tokenized_example ]
|
||||||
[ range-test adaptor_test/type_erased_example ]
|
[ range-test adaptor_test/type_erased_example ]
|
||||||
[ range-test adaptor_test/uniqued_example ]
|
[ range-test adaptor_test/uniqued_example ]
|
||||||
[ range-test algorithm_test/adjacent_find ]
|
[ range-test algorithm_test/adjacent_find ]
|
||||||
|
@ -8,14 +8,16 @@
|
|||||||
//
|
//
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
// For more information, see http://www.boost.org/libs/range/
|
||||||
//
|
//
|
||||||
|
//[adjacent_filtered_example
|
||||||
#include <boost/range/adaptor/adjacent_filtered.hpp>
|
#include <boost/range/adaptor/adjacent_filtered.hpp>
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
#include <algorithm>
|
#include <iterator>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
//<-
|
||||||
#include <boost/range/algorithm_ext/push_back.hpp>
|
#include <boost/range/algorithm_ext/push_back.hpp>
|
||||||
|
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
@ -23,27 +25,32 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void adjacent_filtered_example_test()
|
void adjacent_filtered_example_test()
|
||||||
{
|
//->
|
||||||
using namespace boost::assign;
|
//=int main(int argc, const char* argv[])
|
||||||
using namespace boost::adaptors;
|
{
|
||||||
|
using namespace boost::assign;
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
|
||||||
std::vector<int> input;
|
std::vector<int> input;
|
||||||
input += 1,1,2,2,2,3,4,5,6;
|
input += 1,1,2,2,2,3,4,5,6;
|
||||||
|
|
||||||
boost::copy(
|
boost::copy(
|
||||||
input | adjacent_filtered(std::not_equal_to<int>()),
|
input | adjacent_filtered(std::not_equal_to<int>()),
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
std::ostream_iterator<int>(std::cout, ","));
|
||||||
|
|
||||||
|
//= return 0;
|
||||||
|
//=}
|
||||||
|
//]
|
||||||
|
std::vector<int> reference;
|
||||||
|
reference += 1,2,3,4,5,6;
|
||||||
|
|
||||||
std::vector<int> reference;
|
std::vector<int> test;
|
||||||
reference += 1,2,3,4,5,6;
|
boost::push_back(test, input | adjacent_filtered(std::not_equal_to<int>()));
|
||||||
|
|
||||||
std::vector<int> test;
|
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
||||||
boost::push_back(test, input | adjacent_filtered(std::not_equal_to<int>()));
|
test.begin(), test.end() );
|
||||||
|
}
|
||||||
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
|
||||||
test.begin(), test.end() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::unit_test::test_suite*
|
boost::unit_test::test_suite*
|
||||||
|
@ -8,13 +8,15 @@
|
|||||||
//
|
//
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
// For more information, see http://www.boost.org/libs/range/
|
||||||
//
|
//
|
||||||
|
//[copied_example
|
||||||
#include <boost/range/adaptor/copied.hpp>
|
#include <boost/range/adaptor/copied.hpp>
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
#include <algorithm>
|
#include <iterator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
//<-
|
||||||
#include <boost/range/algorithm_ext/push_back.hpp>
|
#include <boost/range/algorithm_ext/push_back.hpp>
|
||||||
|
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
@ -22,28 +24,32 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void copied_example_test()
|
void copied_example_test()
|
||||||
{
|
//->
|
||||||
using namespace boost::assign;
|
//=int main(int argc, const char* argv[])
|
||||||
using namespace boost::adaptors;
|
{
|
||||||
|
using namespace boost::assign;
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
|
||||||
std::vector<int> input;
|
std::vector<int> input;
|
||||||
input += 1,2,3,4,5,6,7,8,9,10;
|
input += 1,2,3,4,5,6,7,8,9,10;
|
||||||
|
|
||||||
boost::copy(
|
boost::copy(
|
||||||
input | copied(1, 5),
|
input | copied(1, 5),
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
std::ostream_iterator<int>(std::cout, ","));
|
||||||
|
|
||||||
|
//= return 0;
|
||||||
|
//=}
|
||||||
|
//]
|
||||||
|
std::vector<int> reference;
|
||||||
|
reference += 2,3,4,5;
|
||||||
|
|
||||||
std::vector<int> reference;
|
std::vector<int> test;
|
||||||
reference += 2,3,4,5;
|
boost::push_back(test, input | copied(1, 5));
|
||||||
|
|
||||||
std::vector<int> test;
|
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
||||||
boost::push_back(test, input | copied(1, 5));
|
test.begin(), test.end() );
|
||||||
|
}
|
||||||
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
|
||||||
test.begin(), test.end() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::unit_test::test_suite*
|
boost::unit_test::test_suite*
|
||||||
|
@ -8,13 +8,15 @@
|
|||||||
//
|
//
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
// For more information, see http://www.boost.org/libs/range/
|
||||||
//
|
//
|
||||||
|
//[filtered_example
|
||||||
#include <boost/range/adaptor/filtered.hpp>
|
#include <boost/range/adaptor/filtered.hpp>
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
#include <algorithm>
|
#include <iterator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
//<-
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
@ -22,32 +24,39 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
struct is_even
|
//->
|
||||||
{
|
struct is_even
|
||||||
bool operator()( int x ) const { return x % 2 == 0; }
|
{
|
||||||
};
|
bool operator()( int x ) const { return x % 2 == 0; }
|
||||||
|
};
|
||||||
|
|
||||||
void filtered_example_test()
|
//<-
|
||||||
{
|
void filtered_example_test()
|
||||||
using namespace boost::assign;
|
//->
|
||||||
using namespace boost::adaptors;
|
//=int main(int argc, const char* argv[])
|
||||||
|
{
|
||||||
|
using namespace boost::assign;
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
|
||||||
std::vector<int> input;
|
std::vector<int> input;
|
||||||
input += 1,2,3,4,5,6,7,8,9;
|
input += 1,2,3,4,5,6,7,8,9;
|
||||||
|
|
||||||
boost::copy(
|
boost::copy(
|
||||||
input | filtered(is_even()),
|
input | filtered(is_even()),
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
std::ostream_iterator<int>(std::cout, ","));
|
||||||
|
|
||||||
std::vector<int> reference;
|
//= return 0;
|
||||||
reference += 2,4,6,8;
|
//=}
|
||||||
|
//]
|
||||||
|
std::vector<int> reference;
|
||||||
|
reference += 2,4,6,8;
|
||||||
|
|
||||||
std::vector<int> test;
|
std::vector<int> test;
|
||||||
boost::push_back(test, input | filtered(is_even()));
|
boost::push_back(test, input | filtered(is_even()));
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
||||||
test.begin(), test.end() );
|
test.begin(), test.end() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::unit_test::test_suite*
|
boost::unit_test::test_suite*
|
||||||
|
@ -8,13 +8,15 @@
|
|||||||
//
|
//
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
// For more information, see http://www.boost.org/libs/range/
|
||||||
//
|
//
|
||||||
|
//[indexed_example
|
||||||
#include <boost/range/adaptor/indexed.hpp>
|
#include <boost/range/adaptor/indexed.hpp>
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
#include <algorithm>
|
#include <iterator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
//<-
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
@ -22,65 +24,72 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
template<class Iterator>
|
|
||||||
void display_element_and_index(Iterator first, Iterator last)
|
template<class Iterator1, class Iterator2>
|
||||||
|
void check_element_and_index(
|
||||||
|
Iterator1 test_first,
|
||||||
|
Iterator1 test_last,
|
||||||
|
Iterator2 reference_first,
|
||||||
|
Iterator2 reference_last)
|
||||||
|
{
|
||||||
|
BOOST_CHECK_EQUAL( std::distance(test_first, test_last),
|
||||||
|
std::distance(reference_first, reference_last) );
|
||||||
|
|
||||||
|
int reference_index = 0;
|
||||||
|
|
||||||
|
Iterator1 test_it = test_first;
|
||||||
|
Iterator2 reference_it = reference_first;
|
||||||
|
for (; test_it != test_last; ++test_it, ++reference_it, ++reference_index)
|
||||||
{
|
{
|
||||||
for (Iterator it = first; it != last; ++it)
|
BOOST_CHECK_EQUAL( *test_it, *reference_it );
|
||||||
{
|
BOOST_CHECK_EQUAL( test_it.index(), reference_index );
|
||||||
std::cout << "Element = " << *it << " Index = " << it.index() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template<class SinglePassRange>
|
template<class SinglePassRange1, class SinglePassRange2>
|
||||||
void display_element_and_index(const SinglePassRange& rng)
|
void check_element_and_index(
|
||||||
|
const SinglePassRange1& test_rng,
|
||||||
|
const SinglePassRange2& reference_rng)
|
||||||
|
{
|
||||||
|
check_element_and_index(boost::begin(test_rng), boost::end(test_rng),
|
||||||
|
boost::begin(reference_rng), boost::end(reference_rng));
|
||||||
|
}
|
||||||
|
//->
|
||||||
|
template<class Iterator>
|
||||||
|
void display_element_and_index(Iterator first, Iterator last)
|
||||||
|
{
|
||||||
|
for (Iterator it = first; it != last; ++it)
|
||||||
{
|
{
|
||||||
display_element_and_index(boost::begin(rng), boost::end(rng));
|
std::cout << "Element = " << *it << " Index = " << it.index() << std::endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template<class Iterator1, class Iterator2>
|
template<class SinglePassRange>
|
||||||
void check_element_and_index(
|
void display_element_and_index(const SinglePassRange& rng)
|
||||||
Iterator1 test_first,
|
{
|
||||||
Iterator1 test_last,
|
display_element_and_index(boost::begin(rng), boost::end(rng));
|
||||||
Iterator2 reference_first,
|
}
|
||||||
Iterator2 reference_last)
|
|
||||||
{
|
|
||||||
BOOST_CHECK_EQUAL( std::distance(test_first, test_last),
|
|
||||||
std::distance(reference_first, reference_last) );
|
|
||||||
|
|
||||||
int reference_index = 0;
|
//<-
|
||||||
|
void indexed_example_test()
|
||||||
|
//->
|
||||||
|
//=int main(int argc, const char* argv[])
|
||||||
|
{
|
||||||
|
using namespace boost::assign;
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
|
||||||
Iterator1 test_it = test_first;
|
std::vector<int> input;
|
||||||
Iterator2 reference_it = reference_first;
|
input += 10,20,30,40,50,60,70,80,90;
|
||||||
for (; test_it != test_last; ++test_it, ++reference_it, ++reference_index)
|
|
||||||
{
|
|
||||||
BOOST_CHECK_EQUAL( *test_it, *reference_it );
|
|
||||||
BOOST_CHECK_EQUAL( test_it.index(), reference_index );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class SinglePassRange1, class SinglePassRange2>
|
display_element_and_index( input | indexed(0) );
|
||||||
void check_element_and_index(
|
|
||||||
const SinglePassRange1& test_rng,
|
|
||||||
const SinglePassRange2& reference_rng)
|
|
||||||
{
|
|
||||||
check_element_and_index(boost::begin(test_rng), boost::end(test_rng),
|
|
||||||
boost::begin(reference_rng), boost::end(reference_rng));
|
|
||||||
}
|
|
||||||
|
|
||||||
void indexed_example_test()
|
//= return 0;
|
||||||
{
|
//=}
|
||||||
using namespace boost::assign;
|
//]
|
||||||
using namespace boost::adaptors;
|
check_element_and_index(
|
||||||
|
input | indexed(0),
|
||||||
std::vector<int> input;
|
input);
|
||||||
input += 10,20,30,40,50,60,70,80,90;
|
}
|
||||||
|
|
||||||
display_element_and_index( input | indexed(0) );
|
|
||||||
|
|
||||||
check_element_and_index(
|
|
||||||
input | indexed(0),
|
|
||||||
input);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::unit_test::test_suite*
|
boost::unit_test::test_suite*
|
||||||
|
@ -8,13 +8,15 @@
|
|||||||
//
|
//
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
// For more information, see http://www.boost.org/libs/range/
|
||||||
//
|
//
|
||||||
|
//[indirected_example
|
||||||
#include <boost/range/adaptor/indirected.hpp>
|
#include <boost/range/adaptor/indirected.hpp>
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <algorithm>
|
#include <iterator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
//<-
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
@ -22,30 +24,34 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void indirected_example_test()
|
void indirected_example_test()
|
||||||
{
|
//->
|
||||||
using namespace boost::adaptors;
|
//=int main(int argc, const char* argv[])
|
||||||
|
{
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
|
||||||
std::vector<boost::shared_ptr<int> > input;
|
std::vector<boost::shared_ptr<int> > input;
|
||||||
|
|
||||||
for (int i = 0; i < 10; ++i)
|
for (int i = 0; i < 10; ++i)
|
||||||
input.push_back(boost::shared_ptr<int>(new int(i)));
|
input.push_back(boost::shared_ptr<int>(new int(i)));
|
||||||
|
|
||||||
boost::copy(
|
boost::copy(
|
||||||
input | indirected,
|
input | indirected,
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
std::ostream_iterator<int>(std::cout, ","));
|
||||||
|
|
||||||
|
//= return 0;
|
||||||
|
//=}
|
||||||
|
//]
|
||||||
|
std::vector<int> reference;
|
||||||
|
for (int i = 0; i < 10; ++i)
|
||||||
|
reference.push_back(i);
|
||||||
|
|
||||||
std::vector<int> reference;
|
std::vector<int> test;
|
||||||
for (int i = 0; i < 10; ++i)
|
boost::push_back(test, input | indirected);
|
||||||
reference.push_back(i);
|
|
||||||
|
|
||||||
std::vector<int> test;
|
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
||||||
boost::push_back(test, input | indirected);
|
test.begin(), test.end() );
|
||||||
|
}
|
||||||
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
|
||||||
test.begin(), test.end() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::unit_test::test_suite*
|
boost::unit_test::test_suite*
|
||||||
|
@ -8,14 +8,16 @@
|
|||||||
//
|
//
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
// For more information, see http://www.boost.org/libs/range/
|
||||||
//
|
//
|
||||||
|
//[map_keys_example
|
||||||
#include <boost/range/adaptor/map.hpp>
|
#include <boost/range/adaptor/map.hpp>
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
#include <algorithm>
|
#include <iterator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
//<-
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
@ -23,29 +25,33 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void map_keys_example_test()
|
void map_keys_example_test()
|
||||||
{
|
//->
|
||||||
using namespace boost::assign;
|
//=int main(int argc, const char* argv[])
|
||||||
using namespace boost::adaptors;
|
{
|
||||||
|
using namespace boost::assign;
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
|
||||||
std::map<int,int> input;
|
std::map<int,int> input;
|
||||||
for (int i = 0; i < 10; ++i)
|
for (int i = 0; i < 10; ++i)
|
||||||
input.insert(std::make_pair(i, i * 10));
|
input.insert(std::make_pair(i, i * 10));
|
||||||
|
|
||||||
boost::copy(
|
boost::copy(
|
||||||
input | map_keys,
|
input | map_keys,
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
std::ostream_iterator<int>(std::cout, ","));
|
||||||
|
|
||||||
|
//= return 0;
|
||||||
std::vector<int> reference;
|
//=}
|
||||||
reference += 0,1,2,3,4,5,6,7,8,9;
|
//]
|
||||||
|
std::vector<int> reference;
|
||||||
|
reference += 0,1,2,3,4,5,6,7,8,9;
|
||||||
|
|
||||||
std::vector<int> test;
|
std::vector<int> test;
|
||||||
boost::push_back(test, input | map_keys);
|
boost::push_back(test, input | map_keys);
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
||||||
test.begin(), test.end() );
|
test.begin(), test.end() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::unit_test::test_suite*
|
boost::unit_test::test_suite*
|
||||||
|
@ -8,14 +8,16 @@
|
|||||||
//
|
//
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
// For more information, see http://www.boost.org/libs/range/
|
||||||
//
|
//
|
||||||
|
//[map_values_example
|
||||||
#include <boost/range/adaptor/map.hpp>
|
#include <boost/range/adaptor/map.hpp>
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
#include <algorithm>
|
#include <iterator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
//<-
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
@ -23,29 +25,33 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void map_values_example_test()
|
void map_values_example_test()
|
||||||
{
|
//->
|
||||||
using namespace boost::assign;
|
//=int main(int argc, const char* argv[])
|
||||||
using namespace boost::adaptors;
|
{
|
||||||
|
using namespace boost::assign;
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
|
||||||
std::map<int,int> input;
|
std::map<int,int> input;
|
||||||
for (int i = 0; i < 10; ++i)
|
for (int i = 0; i < 10; ++i)
|
||||||
input.insert(std::make_pair(i, i * 10));
|
input.insert(std::make_pair(i, i * 10));
|
||||||
|
|
||||||
boost::copy(
|
boost::copy(
|
||||||
input | map_values,
|
input | map_values,
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
std::ostream_iterator<int>(std::cout, ","));
|
||||||
|
|
||||||
|
//= return 0;
|
||||||
std::vector<int> reference;
|
//=}
|
||||||
reference += 0,10,20,30,40,50,60,70,80,90;
|
//]
|
||||||
|
std::vector<int> reference;
|
||||||
|
reference += 0,10,20,30,40,50,60,70,80,90;
|
||||||
|
|
||||||
std::vector<int> test;
|
std::vector<int> test;
|
||||||
boost::push_back(test, input | map_values);
|
boost::push_back(test, input | map_values);
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
||||||
test.begin(), test.end() );
|
test.begin(), test.end() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::unit_test::test_suite*
|
boost::unit_test::test_suite*
|
||||||
|
@ -8,13 +8,15 @@
|
|||||||
//
|
//
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
// For more information, see http://www.boost.org/libs/range/
|
||||||
//
|
//
|
||||||
|
//[replaced_example
|
||||||
#include <boost/range/adaptor/replaced.hpp>
|
#include <boost/range/adaptor/replaced.hpp>
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
#include <algorithm>
|
#include <iterator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
//<-
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
@ -22,28 +24,32 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void replaced_example_test()
|
void replaced_example_test()
|
||||||
{
|
//->
|
||||||
using namespace boost::adaptors;
|
//=int main(int argc, const char* argv[])
|
||||||
using namespace boost::assign;
|
{
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
using namespace boost::assign;
|
||||||
|
|
||||||
std::vector<int> input;
|
std::vector<int> input;
|
||||||
input += 1,2,3,2,5,2,7,2,9;
|
input += 1,2,3,2,5,2,7,2,9;
|
||||||
|
|
||||||
boost::copy(
|
boost::copy(
|
||||||
input | replaced(2, 10),
|
input | replaced(2, 10),
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
std::ostream_iterator<int>(std::cout, ","));
|
||||||
|
|
||||||
|
//= return 0;
|
||||||
|
//=}
|
||||||
|
//]
|
||||||
|
std::vector<int> reference;
|
||||||
|
reference += 1,10,3,10,5,10,7,10,9;
|
||||||
|
|
||||||
std::vector<int> reference;
|
std::vector<int> test;
|
||||||
reference += 1,10,3,10,5,10,7,10,9;
|
boost::push_back(test, input | replaced(2, 10));
|
||||||
|
|
||||||
std::vector<int> test;
|
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
||||||
boost::push_back(test, input | replaced(2, 10));
|
test.begin(), test.end() );
|
||||||
|
}
|
||||||
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
|
||||||
test.begin(), test.end() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::unit_test::test_suite*
|
boost::unit_test::test_suite*
|
||||||
|
@ -8,13 +8,15 @@
|
|||||||
//
|
//
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
// For more information, see http://www.boost.org/libs/range/
|
||||||
//
|
//
|
||||||
|
//[replaced_if_example
|
||||||
#include <boost/range/adaptor/replaced_if.hpp>
|
#include <boost/range/adaptor/replaced_if.hpp>
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
#include <algorithm>
|
#include <iterator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
//<-
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
@ -22,32 +24,39 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
struct is_even
|
//->
|
||||||
{
|
struct is_even
|
||||||
bool operator()(int x) const { return x % 2 == 0; }
|
{
|
||||||
};
|
bool operator()(int x) const { return x % 2 == 0; }
|
||||||
|
};
|
||||||
|
|
||||||
void replaced_if_example_test()
|
//<-
|
||||||
{
|
void replaced_if_example_test()
|
||||||
using namespace boost::adaptors;
|
//->
|
||||||
using namespace boost::assign;
|
//=int main(int argc, const char* argv[])
|
||||||
|
{
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
using namespace boost::assign;
|
||||||
|
|
||||||
std::vector<int> input;
|
std::vector<int> input;
|
||||||
input += 1,2,3,4,5,6,7,8,9;
|
input += 1,2,3,4,5,6,7,8,9;
|
||||||
|
|
||||||
boost::copy(
|
boost::copy(
|
||||||
input | replaced_if(is_even(), 10),
|
input | replaced_if(is_even(), 10),
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
std::ostream_iterator<int>(std::cout, ","));
|
||||||
|
|
||||||
std::vector<int> reference;
|
//= return 0;
|
||||||
reference += 1,10,3,10,5,10,7,10,9;
|
//=}
|
||||||
|
//]
|
||||||
|
std::vector<int> reference;
|
||||||
|
reference += 1,10,3,10,5,10,7,10,9;
|
||||||
|
|
||||||
std::vector<int> test;
|
std::vector<int> test;
|
||||||
boost::push_back(test, input | replaced_if(is_even(), 10));
|
boost::push_back(test, input | replaced_if(is_even(), 10));
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
||||||
test.begin(), test.end() );
|
test.begin(), test.end() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::unit_test::test_suite*
|
boost::unit_test::test_suite*
|
||||||
|
@ -8,13 +8,15 @@
|
|||||||
//
|
//
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
// For more information, see http://www.boost.org/libs/range/
|
||||||
//
|
//
|
||||||
|
//[reversed_example
|
||||||
#include <boost/range/adaptor/reversed.hpp>
|
#include <boost/range/adaptor/reversed.hpp>
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
#include <algorithm>
|
#include <iterator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
//<-
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
@ -22,25 +24,29 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void reversed_example_test()
|
void reversed_example_test()
|
||||||
{
|
//->
|
||||||
using namespace boost::adaptors;
|
//=int main(int argc, const char* argv[])
|
||||||
using namespace boost::assign;
|
{
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
using namespace boost::assign;
|
||||||
|
|
||||||
std::vector<int> input;
|
std::vector<int> input;
|
||||||
input += 1,2,3,4,5,6,7,8,9;
|
input += 1,2,3,4,5,6,7,8,9;
|
||||||
|
|
||||||
boost::copy(
|
boost::copy(
|
||||||
input | reversed,
|
input | reversed,
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
std::ostream_iterator<int>(std::cout, ","));
|
||||||
|
|
||||||
|
//= return 0;
|
||||||
|
//=}
|
||||||
|
//]
|
||||||
|
std::vector<int> test;
|
||||||
|
boost::push_back(test, input | reversed);
|
||||||
|
|
||||||
std::vector<int> test;
|
BOOST_CHECK_EQUAL_COLLECTIONS( input.rbegin(), input.rend(),
|
||||||
boost::push_back(test, input | reversed);
|
test.begin(), test.end() );
|
||||||
|
}
|
||||||
BOOST_CHECK_EQUAL_COLLECTIONS( input.rbegin(), input.rend(),
|
|
||||||
test.begin(), test.end() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::unit_test::test_suite*
|
boost::unit_test::test_suite*
|
||||||
|
@ -8,13 +8,15 @@
|
|||||||
//
|
//
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
// For more information, see http://www.boost.org/libs/range/
|
||||||
//
|
//
|
||||||
|
//[sliced_example
|
||||||
#include <boost/range/adaptor/sliced.hpp>
|
#include <boost/range/adaptor/sliced.hpp>
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
#include <algorithm>
|
#include <iterator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
//<-
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
@ -22,28 +24,32 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void sliced_example_test()
|
void sliced_example_test()
|
||||||
{
|
//->
|
||||||
using namespace boost::adaptors;
|
//=int main(int argc, const char* argv[])
|
||||||
using namespace boost::assign;
|
{
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
using namespace boost::assign;
|
||||||
|
|
||||||
std::vector<int> input;
|
std::vector<int> input;
|
||||||
input += 1,2,3,4,5,6,7,8,9;
|
input += 1,2,3,4,5,6,7,8,9;
|
||||||
|
|
||||||
boost::copy(
|
boost::copy(
|
||||||
input | sliced(2, 5),
|
input | sliced(2, 5),
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
std::ostream_iterator<int>(std::cout, ","));
|
||||||
|
|
||||||
|
//= return 0;
|
||||||
|
//=}
|
||||||
|
//]
|
||||||
|
std::vector<int> reference;
|
||||||
|
reference += 3,4,5;
|
||||||
|
|
||||||
std::vector<int> reference;
|
std::vector<int> test;
|
||||||
reference += 3,4,5;
|
boost::push_back(test, input | sliced(2, 5));
|
||||||
|
|
||||||
std::vector<int> test;
|
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
||||||
boost::push_back(test, input | sliced(2, 5));
|
test.begin(), test.end() );
|
||||||
|
}
|
||||||
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
|
||||||
test.begin(), test.end() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::unit_test::test_suite*
|
boost::unit_test::test_suite*
|
||||||
|
@ -8,13 +8,15 @@
|
|||||||
//
|
//
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
// For more information, see http://www.boost.org/libs/range/
|
||||||
//
|
//
|
||||||
|
//[strided_example
|
||||||
#include <boost/range/adaptor/strided.hpp>
|
#include <boost/range/adaptor/strided.hpp>
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
#include <algorithm>
|
#include <iterator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
//<-
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
@ -22,28 +24,32 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void strided_example_test()
|
void strided_example_test()
|
||||||
{
|
//->
|
||||||
using namespace boost::adaptors;
|
//=int main(int argc, const char* argv[])
|
||||||
using namespace boost::assign;
|
{
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
using namespace boost::assign;
|
||||||
|
|
||||||
std::vector<int> input;
|
std::vector<int> input;
|
||||||
input += 1,2,3,4,5,6,7,8,9,10;
|
input += 1,2,3,4,5,6,7,8,9,10;
|
||||||
|
|
||||||
boost::copy(
|
boost::copy(
|
||||||
input | strided(2),
|
input | strided(2),
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
std::ostream_iterator<int>(std::cout, ","));
|
||||||
|
|
||||||
|
//= return 0;
|
||||||
|
//=}
|
||||||
|
//]
|
||||||
|
std::vector<int> reference;
|
||||||
|
reference += 1,3,5,7,9;
|
||||||
|
|
||||||
std::vector<int> reference;
|
std::vector<int> test;
|
||||||
reference += 1,3,5,7,9;
|
boost::push_back(test, input | strided(2));
|
||||||
|
|
||||||
std::vector<int> test;
|
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
||||||
boost::push_back(test, input | strided(2));
|
test.begin(), test.end() );
|
||||||
|
}
|
||||||
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
|
||||||
test.begin(), test.end() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::unit_test::test_suite*
|
boost::unit_test::test_suite*
|
||||||
|
65
test/adaptor_test/tokenized_example.cpp
Normal file
65
test/adaptor_test/tokenized_example.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
// Boost.Range library
|
||||||
|
//
|
||||||
|
// Copyright Neil Groves 2009. Use, modification and
|
||||||
|
// distribution is subject to the Boost Software License, Version
|
||||||
|
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// For more information, see http://www.boost.org/libs/range/
|
||||||
|
//
|
||||||
|
//[tokenized_example
|
||||||
|
#include <boost/range/adaptor/tokenized.hpp>
|
||||||
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
|
#include <boost/assign.hpp>
|
||||||
|
#include <iterator>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
//<-
|
||||||
|
#include <boost/test/test_tools.hpp>
|
||||||
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
|
#include <boost/range/algorithm_ext/push_back.hpp>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
void tokenized_example_test()
|
||||||
|
//->
|
||||||
|
//=int main(int argc, const char* argv[])
|
||||||
|
{
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
|
||||||
|
typedef boost::sub_match< std::string::iterator > match_type;
|
||||||
|
|
||||||
|
std::string input = " a b c d e f g hijklmnopqrstuvwxyz";
|
||||||
|
boost::copy(
|
||||||
|
input | tokenized(boost::regex("\\w+")),
|
||||||
|
std::ostream_iterator<match_type>(std::cout, "\n"));
|
||||||
|
|
||||||
|
//= return 0;
|
||||||
|
//=}
|
||||||
|
//]
|
||||||
|
using namespace boost::assign;
|
||||||
|
|
||||||
|
std::vector<std::string> reference;
|
||||||
|
reference += "a","b","c","d","e","f","g","hijklmnopqrstuvwxyz";
|
||||||
|
|
||||||
|
std::vector<match_type> test;
|
||||||
|
boost::push_back(test, input | tokenized(boost::regex("\\w+")));
|
||||||
|
|
||||||
|
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
||||||
|
test.begin(), test.end() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::unit_test::test_suite*
|
||||||
|
init_unit_test_suite(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
boost::unit_test::test_suite* test
|
||||||
|
= BOOST_TEST_SUITE( "RangeTestSuite.adaptor.tokenized_example" );
|
||||||
|
|
||||||
|
test->add( BOOST_TEST_CASE( &tokenized_example_test ) );
|
||||||
|
|
||||||
|
return test;
|
||||||
|
}
|
@ -8,13 +8,15 @@
|
|||||||
//
|
//
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
// For more information, see http://www.boost.org/libs/range/
|
||||||
//
|
//
|
||||||
|
//[transformed_example
|
||||||
#include <boost/range/adaptor/transformed.hpp>
|
#include <boost/range/adaptor/transformed.hpp>
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
#include <algorithm>
|
#include <iterator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
//<-
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
@ -22,34 +24,40 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
struct double_int
|
//->
|
||||||
{
|
struct double_int
|
||||||
typedef int result_type;
|
{
|
||||||
int operator()(int x) const { return x * 2; }
|
typedef int result_type;
|
||||||
};
|
int operator()(int x) const { return x * 2; }
|
||||||
|
};
|
||||||
|
|
||||||
void transformed_example_test()
|
//<-
|
||||||
{
|
void transformed_example_test()
|
||||||
using namespace boost::adaptors;
|
//->
|
||||||
using namespace boost::assign;
|
//=int main(int argc, const char* argv[])
|
||||||
|
{
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
using namespace boost::assign;
|
||||||
|
|
||||||
std::vector<int> input;
|
std::vector<int> input;
|
||||||
input += 1,2,3,4,5,6,7,8,9,10;
|
input += 1,2,3,4,5,6,7,8,9,10;
|
||||||
|
|
||||||
boost::copy(
|
boost::copy(
|
||||||
input | transformed(double_int()),
|
input | transformed(double_int()),
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
std::ostream_iterator<int>(std::cout, ","));
|
||||||
|
|
||||||
|
//= return 0;
|
||||||
|
//=}
|
||||||
|
//]
|
||||||
|
std::vector<int> reference;
|
||||||
|
reference += 2,4,6,8,10,12,14,16,18,20;
|
||||||
|
|
||||||
std::vector<int> reference;
|
std::vector<int> test;
|
||||||
reference += 2,4,6,8,10,12,14,16,18,20;
|
boost::push_back(test, input | transformed(double_int()));
|
||||||
|
|
||||||
std::vector<int> test;
|
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
||||||
boost::push_back(test, input | transformed(double_int()));
|
test.begin(), test.end() );
|
||||||
|
}
|
||||||
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
|
||||||
test.begin(), test.end() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::unit_test::test_suite*
|
boost::unit_test::test_suite*
|
||||||
|
@ -8,15 +8,16 @@
|
|||||||
//
|
//
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
// For more information, see http://www.boost.org/libs/range/
|
||||||
//
|
//
|
||||||
|
//[type_erased_example
|
||||||
#include <boost/range/adaptor/type_erased.hpp>
|
#include <boost/range/adaptor/type_erased.hpp>
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <algorithm>
|
#include <iterator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
//<-
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
@ -26,6 +27,7 @@ namespace
|
|||||||
{
|
{
|
||||||
namespace type_erased_example
|
namespace type_erased_example
|
||||||
{
|
{
|
||||||
|
//->
|
||||||
|
|
||||||
// The client interface from an OO perspective merely requires a sequence
|
// The client interface from an OO perspective merely requires a sequence
|
||||||
// of integers that can be forward traversed
|
// of integers that can be forward traversed
|
||||||
@ -99,6 +101,13 @@ namespace client
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=int main(int argc, const char* argv[])
|
||||||
|
//={
|
||||||
|
//= client::run();
|
||||||
|
//= return 0;
|
||||||
|
//=}
|
||||||
|
//]
|
||||||
|
|
||||||
} // namespace type_erased_example
|
} // namespace type_erased_example
|
||||||
} // namespace boost_range_test
|
} // namespace boost_range_test
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
@ -8,13 +8,15 @@
|
|||||||
//
|
//
|
||||||
// For more information, see http://www.boost.org/libs/range/
|
// For more information, see http://www.boost.org/libs/range/
|
||||||
//
|
//
|
||||||
|
//[uniqued_example
|
||||||
#include <boost/range/adaptor/uniqued.hpp>
|
#include <boost/range/adaptor/uniqued.hpp>
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
#include <algorithm>
|
#include <iterator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
//<-
|
||||||
#include <boost/range/algorithm_ext/push_back.hpp>
|
#include <boost/range/algorithm_ext/push_back.hpp>
|
||||||
|
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
@ -22,27 +24,32 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void uniqued_example_test()
|
void uniqued_example_test()
|
||||||
{
|
//->
|
||||||
using namespace boost::assign;
|
//=int main(int argc, const char* argv[])
|
||||||
using namespace boost::adaptors;
|
{
|
||||||
|
using namespace boost::assign;
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
|
||||||
std::vector<int> input;
|
std::vector<int> input;
|
||||||
input += 1,1,2,2,2,3,4,5,6;
|
input += 1,1,2,2,2,3,4,5,6;
|
||||||
|
|
||||||
boost::copy(
|
boost::copy(
|
||||||
input | uniqued,
|
input | uniqued,
|
||||||
std::ostream_iterator<int>(std::cout, ","));
|
std::ostream_iterator<int>(std::cout, ","));
|
||||||
|
|
||||||
std::vector<int> reference;
|
//= return 0;
|
||||||
reference += 1,2,3,4,5,6;
|
//=}
|
||||||
|
//]
|
||||||
|
std::vector<int> reference;
|
||||||
|
reference += 1,2,3,4,5,6;
|
||||||
|
|
||||||
std::vector<int> test;
|
std::vector<int> test;
|
||||||
boost::push_back( test, input | uniqued );
|
boost::push_back( test, input | uniqued );
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
||||||
test.begin(), test.end() );
|
test.begin(), test.end() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::unit_test::test_suite*
|
boost::unit_test::test_suite*
|
||||||
|
Reference in New Issue
Block a user