• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>replace</title>
5<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../../../index.html" title="Chapter 1. Fusion 2.2">
8<link rel="up" href="../functions.html" title="Functions">
9<link rel="prev" href="transform.html" title="transform">
10<link rel="next" href="replace_if.html" title="replace_if">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="transform.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../functions.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="replace_if.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h5 class="title">
27<a name="fusion.algorithm.transformation.functions.replace"></a><a class="link" href="replace.html" title="replace">replace</a>
28</h5></div></div></div>
29<h6>
30<a name="fusion.algorithm.transformation.functions.replace.h0"></a>
31            <span class="phrase"><a name="fusion.algorithm.transformation.functions.replace.description"></a></span><a class="link" href="replace.html#fusion.algorithm.transformation.functions.replace.description">Description</a>
32          </h6>
33<p>
34            Replaces each value within a sequence of a given type and value with
35            a new value.
36          </p>
37<h6>
38<a name="fusion.algorithm.transformation.functions.replace.h1"></a>
39            <span class="phrase"><a name="fusion.algorithm.transformation.functions.replace.synopsis"></a></span><a class="link" href="replace.html#fusion.algorithm.transformation.functions.replace.synopsis">Synopsis</a>
40          </h6>
41<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span>
42    <span class="keyword">typename</span> <span class="identifier">Sequence</span><span class="special">,</span>
43    <span class="keyword">typename</span> <span class="identifier">T</span>
44    <span class="special">&gt;</span>
45<span class="keyword">typename</span> <a class="link" href="../metafunctions/replace.html" title="replace"><code class="computeroutput"><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">replace</span></code></a><span class="special">&lt;</span><span class="identifier">Sequence</span> <span class="keyword">const</span><span class="special">,</span> <span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">replace</span><span class="special">(</span>
46    <span class="identifier">Sequence</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">seq</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">old_value</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">new_value</span><span class="special">);</span>
47</pre>
48<div class="table">
49<a name="fusion.algorithm.transformation.functions.replace.t0"></a><p class="title"><b>Table 1.70. Parameters</b></p>
50<div class="table-contents"><table class="table" summary="Parameters">
51<colgroup>
52<col>
53<col>
54<col>
55</colgroup>
56<thead><tr>
57<th>
58                    <p>
59                      Parameter
60                    </p>
61                  </th>
62<th>
63                    <p>
64                      Requirement
65                    </p>
66                  </th>
67<th>
68                    <p>
69                      Description
70                    </p>
71                  </th>
72</tr></thead>
73<tbody>
74<tr>
75<td>
76                    <p>
77                      <code class="computeroutput"><span class="identifier">seq</span></code>
78                    </p>
79                  </td>
80<td>
81                    <p>
82                      A model of <a class="link" href="../../../sequence/concepts/forward_sequence.html" title="Forward Sequence">Forward
83                      Sequence</a>, <code class="computeroutput"><span class="identifier">e</span>
84                      <span class="special">==</span> <span class="identifier">old_value</span></code>
85                      is a valid expression, convertible to <code class="computeroutput"><span class="keyword">bool</span></code>,
86                      for each element <code class="computeroutput"><span class="identifier">e</span></code>
87                      in <code class="computeroutput"><span class="identifier">seq</span></code> with
88                      type convertible to <code class="computeroutput"><span class="identifier">T</span></code>
89                    </p>
90                  </td>
91<td>
92                    <p>
93                      Operation's argument
94                    </p>
95                  </td>
96</tr>
97<tr>
98<td>
99                    <p>
100                      <code class="computeroutput"><span class="identifier">old_value</span></code>
101                    </p>
102                  </td>
103<td>
104                    <p>
105                      Any type
106                    </p>
107                  </td>
108<td>
109                    <p>
110                      Value to replace
111                    </p>
112                  </td>
113</tr>
114<tr>
115<td>
116                    <p>
117                      <code class="computeroutput"><span class="identifier">new_value</span></code>
118                    </p>
119                  </td>
120<td>
121                    <p>
122                      Any type
123                    </p>
124                  </td>
125<td>
126                    <p>
127                      Replacement value
128                    </p>
129                  </td>
130</tr>
131</tbody>
132</table></div>
133</div>
134<br class="table-break"><h6>
135<a name="fusion.algorithm.transformation.functions.replace.h2"></a>
136            <span class="phrase"><a name="fusion.algorithm.transformation.functions.replace.expression_semantics"></a></span><a class="link" href="replace.html#fusion.algorithm.transformation.functions.replace.expression_semantics">Expression
137            Semantics</a>
138          </h6>
139<pre class="programlisting"><a class="link" href="replace.html" title="replace"><code class="computeroutput"><span class="identifier">replace</span></code></a><span class="special">(</span><span class="identifier">seq</span><span class="special">,</span> <span class="identifier">old_value</span><span class="special">,</span> <span class="identifier">new_value</span><span class="special">);</span>
140</pre>
141<p>
142            <span class="bold"><strong>Return type</strong></span>: A model of <a class="link" href="../../../sequence/concepts/forward_sequence.html" title="Forward Sequence">Forward
143            Sequence</a>.
144          </p>
145<p>
146            <span class="bold"><strong>Semantics</strong></span>: Returns a new sequence with
147            all the values of <code class="computeroutput"><span class="identifier">seq</span></code>
148            with <code class="computeroutput"><span class="identifier">new_value</span></code> assigned
149            to elements with the same type and equal to <code class="computeroutput"><span class="identifier">old_value</span></code>.
150          </p>
151<h6>
152<a name="fusion.algorithm.transformation.functions.replace.h3"></a>
153            <span class="phrase"><a name="fusion.algorithm.transformation.functions.replace.complexity"></a></span><a class="link" href="replace.html#fusion.algorithm.transformation.functions.replace.complexity">Complexity</a>
154          </h6>
155<p>
156            Constant. Returns a view which is lazily evaluated.
157          </p>
158<h6>
159<a name="fusion.algorithm.transformation.functions.replace.h4"></a>
160            <span class="phrase"><a name="fusion.algorithm.transformation.functions.replace.header"></a></span><a class="link" href="replace.html#fusion.algorithm.transformation.functions.replace.header">Header</a>
161          </h6>
162<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">fusion</span><span class="special">/</span><span class="identifier">algorithm</span><span class="special">/</span><span class="identifier">transformation</span><span class="special">/</span><span class="identifier">replace</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
163<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">fusion</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">replace</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
164</pre>
165<h6>
166<a name="fusion.algorithm.transformation.functions.replace.h5"></a>
167            <span class="phrase"><a name="fusion.algorithm.transformation.functions.replace.example"></a></span><a class="link" href="replace.html#fusion.algorithm.transformation.functions.replace.example">Example</a>
168          </h6>
169<pre class="programlisting"><span class="identifier">assert</span><span class="special">(</span><a class="link" href="replace.html" title="replace"><code class="computeroutput"><span class="identifier">replace</span></code></a><span class="special">(</span><a class="link" href="../../../container/generation/functions/make_vector.html" title="make_vector"><code class="computeroutput"><span class="identifier">make_vector</span></code></a><span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="number">2</span><span class="special">),</span> <span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">)</span> <span class="special">==</span> <a class="link" href="../../../container/generation/functions/make_vector.html" title="make_vector"><code class="computeroutput"><span class="identifier">make_vector</span></code></a><span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="number">3</span><span class="special">));</span>
170</pre>
171</div>
172<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
173<td align="left"></td>
174<td align="right"><div class="copyright-footer">Copyright © 2001-2006, 2011, 2012 Joel de Guzman,
175      Dan Marsden, Tobias Schwinger<p>
176        Distributed under the Boost Software License, Version 1.0. (See accompanying
177        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
178      </p>
179</div></td>
180</tr></table>
181<hr>
182<div class="spirit-nav">
183<a accesskey="p" href="transform.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../functions.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="replace_if.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
184</div>
185</body>
186</html>
187