forked from boostorg/range
Boost.RangeEx merged into Boost.Range
[SVN r60897]
This commit is contained in:
1 parent
1461479a17
commit
b0d1db7c2e
471 files changed
+48610
-2065
No files matched your search
Executable
+107
@@ -0,0 +1,107 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Boost.Range Range Adaptors </title>
|
||||
<link rel="stylesheet" href="../style.css" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<table border="0" >
|
||||
<tr>
|
||||
<td ><img src="../../../boost.png" border="0" /></td>
|
||||
<td ><h1 align="center">Boost.Range </h1></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2> Range Adaptors </h2>
|
||||
|
||||
<hr />
|
||||
<a name="replaced"></a>
|
||||
<h4><code>replaced</code></h4>
|
||||
<blockquote>
|
||||
<pre>rng | boost::adaptors::replaced( new_value, old_value )</pre>
|
||||
<pre>boost::make_replaced_range( rng, new_value, old_value )</pre>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Precondition:</b>
|
||||
<ul>
|
||||
<li>
|
||||
<code>new_value</code> is convertible to the value-type of
|
||||
the range.
|
||||
</li>
|
||||
<li>
|
||||
<code>old_value</code> is convertible to the value-type of
|
||||
the range.
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<b>Postcondition:</b>
|
||||
For all elements <code>x</code> in the returned range, the value
|
||||
<code>x</code> is equal to the value of
|
||||
<code>(y == old_value) ? new_value : y</code>
|
||||
where <code>y</code> is the corresponding element in the original
|
||||
range.
|
||||
</li>
|
||||
<li>
|
||||
<b>Range Category:</b>
|
||||
ForwardRange
|
||||
</li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h3>Example</h3>
|
||||
<pre>
|
||||
<span class="keyword">#include</span> <boost/range/adaptor/replaced.hpp>
|
||||
<span class="keyword">#include</span> <boost/range/algorithm/copy.hpp>
|
||||
<span class="keyword">#include</span> <boost/assign.hpp>
|
||||
<span class="keyword">#include</span> <algorithm>
|
||||
<span class="keyword">#include</span> <iostream>
|
||||
<span class="keyword">#include</span> <vector>
|
||||
|
||||
<span class="keyword">int</span> main(<span class="keyword">int</span> argc, <span class="keyword">const char</span>* argv[])
|
||||
{
|
||||
<span class="keyword">using namespace</span> boost::adaptors;
|
||||
<span class="keyword">using namespace</span> boost::assign;
|
||||
|
||||
std::vector<<span class="keyword">int</span>> input;
|
||||
input += 1,2,3,2,5,2,7,2,9;
|
||||
|
||||
boost::copy(
|
||||
input | replaced(2, 10),
|
||||
std::ostream_iterator<<span class="keyword">int</span>>(std::cout, ","));
|
||||
|
||||
<span class="keyword">return</span> 0;
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
This produces the output: <br />
|
||||
<code>
|
||||
1,10,3,10,5,10,7,10,9
|
||||
</code>
|
||||
</p>
|
||||
|
||||
<hr />
|
||||
<p>
|
||||
(C) Copyright Neil Groves 2009
|
||||
(C) Copyright Thorsten Ottosen 2003-2004
|
||||
</p>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in new issue
Block a user