• 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. Range 2.0">
8<link rel="up" href="../mutating.html" title="Mutating algorithms">
9<link rel="prev" href="remove_if.html" title="remove_if">
10<link rel="next" href="replace_copy.html" title="replace_copy">
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="remove_if.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../mutating.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_copy.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h5 class="title">
27<a name="range.reference.algorithms.mutating.replace"></a><a class="link" href="replace.html" title="replace">replace</a>
28</h5></div></div></div>
29<h6>
30<a name="range.reference.algorithms.mutating.replace.h0"></a>
31            <span class="phrase"><a name="range.reference.algorithms.mutating.replace.prototype"></a></span><a class="link" href="replace.html#range.reference.algorithms.mutating.replace.prototype">Prototype</a>
32          </h6>
33<p>
34</p>
35<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span>
36    <span class="keyword">class</span> <span class="identifier">ForwardRange</span><span class="special">,</span>
37    <span class="keyword">class</span> <span class="identifier">Value</span>
38    <span class="special">&gt;</span>
39<span class="identifier">ForwardRange</span><span class="special">&amp;</span> <span class="identifier">replace</span><span class="special">(</span><span class="identifier">ForwardRange</span><span class="special">&amp;</span> <span class="identifier">rng</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Value</span><span class="special">&amp;</span> <span class="identifier">what</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Value</span><span class="special">&amp;</span> <span class="identifier">with_what</span><span class="special">);</span>
40
41<span class="keyword">template</span><span class="special">&lt;</span>
42    <span class="keyword">class</span> <span class="identifier">ForwardRange</span><span class="special">,</span>
43    <span class="keyword">class</span> <span class="identifier">UnaryPredicate</span>
44    <span class="special">&gt;</span>
45<span class="keyword">const</span> <span class="identifier">ForwardRange</span><span class="special">&amp;</span> <span class="identifier">replace</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">ForwardRange</span><span class="special">&amp;</span> <span class="identifier">rng</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Value</span><span class="special">&amp;</span> <span class="identifier">what</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Value</span><span class="special">&amp;</span> <span class="identifier">with_what</span><span class="special">);</span>
46</pre>
47<p>
48          </p>
49<h6>
50<a name="range.reference.algorithms.mutating.replace.h1"></a>
51            <span class="phrase"><a name="range.reference.algorithms.mutating.replace.description"></a></span><a class="link" href="replace.html#range.reference.algorithms.mutating.replace.description">Description</a>
52          </h6>
53<p>
54            <code class="computeroutput"><span class="identifier">replace</span></code> every element
55            in <code class="computeroutput"><span class="identifier">rng</span></code> equal to <code class="computeroutput"><span class="identifier">what</span></code> with <code class="computeroutput"><span class="identifier">with_what</span></code>.
56            Return a reference to <code class="computeroutput"><span class="identifier">rng</span></code>.
57          </p>
58<h6>
59<a name="range.reference.algorithms.mutating.replace.h2"></a>
60            <span class="phrase"><a name="range.reference.algorithms.mutating.replace.definition"></a></span><a class="link" href="replace.html#range.reference.algorithms.mutating.replace.definition">Definition</a>
61          </h6>
62<p>
63            Defined in the header file <code class="computeroutput"><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">replace</span><span class="special">.</span><span class="identifier">hpp</span></code>
64          </p>
65<h6>
66<a name="range.reference.algorithms.mutating.replace.h3"></a>
67            <span class="phrase"><a name="range.reference.algorithms.mutating.replace.requirements"></a></span><a class="link" href="replace.html#range.reference.algorithms.mutating.replace.requirements">Requirements</a>
68          </h6>
69<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
70<li class="listitem">
71                <code class="computeroutput"><span class="identifier">ForwardRange</span></code> is a
72                model of the <a class="link" href="../../../concepts/forward_range.html" title="Forward Range">Forward
73                Range</a> Concept.
74              </li>
75<li class="listitem">
76                <code class="computeroutput"><span class="identifier">ForwardRange</span></code> is mutable.
77              </li>
78<li class="listitem">
79                <code class="computeroutput"><span class="identifier">Value</span></code> is convertible
80                to <code class="computeroutput"><span class="identifier">ForwardRange</span></code>'s
81                value type.
82              </li>
83<li class="listitem">
84                <code class="computeroutput"><span class="identifier">Value</span></code> is a model
85                of the <code class="computeroutput"><span class="identifier">AssignableConcept</span></code>.
86              </li>
87<li class="listitem">
88                <code class="computeroutput"><span class="identifier">Value</span></code> is a model
89                of the <code class="computeroutput"><span class="identifier">EqualityComparableConcept</span></code>,
90                and may be compared for equality with objects of <code class="computeroutput"><span class="identifier">ForwardRange</span></code>'s
91                value type.
92              </li>
93</ul></div>
94<h6>
95<a name="range.reference.algorithms.mutating.replace.h4"></a>
96            <span class="phrase"><a name="range.reference.algorithms.mutating.replace.complexity"></a></span><a class="link" href="replace.html#range.reference.algorithms.mutating.replace.complexity">Complexity</a>
97          </h6>
98<p>
99            Linear. <code class="computeroutput"><span class="identifier">replace</span></code> performs
100            exactly <code class="computeroutput"><span class="identifier">distance</span><span class="special">(</span><span class="identifier">rng</span><span class="special">)</span></code>
101            comparisons for equality and at most <code class="computeroutput"><span class="identifier">distance</span><span class="special">(</span><span class="identifier">rng</span><span class="special">)</span></code> assignments.
102          </p>
103</div>
104<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
105<td align="left"></td>
106<td align="right"><div class="copyright-footer">Copyright © 2003-2010 Thorsten Ottosen,
107      Neil Groves<p>
108        Distributed under the Boost Software License, Version 1.0. (See accompanying
109        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>)
110      </p>
111</div></td>
112</tr></table>
113<hr>
114<div class="spirit-nav">
115<a accesskey="p" href="remove_if.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../mutating.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_copy.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
116</div>
117</body>
118</html>
119