mirror of
https://github.com/boostorg/mpl.git
synced 2026-01-26 17:02:20 +01:00
61 lines
3.1 KiB
HTML
61 lines
3.1 KiB
HTML
<!doctype html public "-//ietf//dtd html//en">
|
|
<html><head><title>boost::mpl::Reference/replace</title>
|
|
<link rel="stylesheet" href="../mpl_wiki.css">
|
|
</head><body bgcolor="white">
|
|
<h1><a href="../Table_of_Content.html"><img src="../mpl_logo.jpg" alt="[Home]" border=0 align="right"></a>replace</h1><h3>Synopsis</h3>
|
|
<p>
|
|
<pre>
|
|
template<
|
|
typename Sequence
|
|
, typename OldType
|
|
, typename NewType
|
|
>
|
|
struct replace
|
|
{
|
|
typedef <em>unspecified</em> type;
|
|
};
|
|
</pre>
|
|
<p>
|
|
<h3>Description</h3>
|
|
<p>
|
|
Performs a replacement operation on the sequence. The algorithm returns a new sequence which contains all the elements from <code>[begin<Sequence>::type, end<Sequence>::type)</code> range where every type identical to <code>OldType</code> has been replaced with a <code>NewType</code>. The result sequence preserves all the functional and performance characteristics of the original <code>Sequence</code>, including its size, but not identity.
|
|
<p>
|
|
<h3>Definition</h3>
|
|
<p>
|
|
<pre>
|
|
#include "<a href="../../../../../\boost/mpl/replace.hpp">boost/mpl/replace.hpp</a>"
|
|
</pre>
|
|
<p>
|
|
<h3>Parameters</h3>
|
|
<table border="1">
|
|
<tr><th> Parameter </th><th> Requirement </th><th> Description </th></tr>
|
|
<tr><td><code>Sequence</code></td><td>A model of <a href="../Extensible_Sequence.html">Extensible Sequence</a></td><td>The original sequence. </td></tr>
|
|
<tr><td><code>OldType</code></td><td>A type</td><td>A type to be replaced. </td></tr>
|
|
<tr><td><code>NewType</code></td><td>A type</td><td>A type to replace with. </td></tr>
|
|
</table>
|
|
<p>
|
|
<h3>Expression semantics</h3>
|
|
<p>
|
|
<table border="1">
|
|
<tr><th> Expression </th><th> Expression type </th><th> Precondition </th><th> Semantics </th><th> Postcondition </th></tr>
|
|
<tr><td><code>typedef replace<Sequence,OldType,NewType>::type s;</code></td><td>A model of <a href="../Extensible_Sequence.html">Extensible Sequence</a></td><td></td><td>Equivalent to <code>typedef replace_if< Sequence,NewType,is_same<_,OldType> >::type t;</code>.</td><td></td></tr>
|
|
</table>
|
|
<p>
|
|
<h3>Complexity</h3>
|
|
<p>
|
|
Linear. Performs exactly <code><a href="../Reference/size.html">size</a><Sequence>::type::value</code> comparisons for equality, and at most <code><a href="../Reference/size.html">size</a><Sequence>::type::value</code> insertions.
|
|
<p>
|
|
<h3>Example</h3>
|
|
<p>
|
|
<pre>
|
|
typedef <a href="../Reference/list.html">list</a><int,float,char,float,float,double>::type types;
|
|
typedef replace< types,float,double >::type result;
|
|
typedef <a href="../Reference/list.html">list</a><int,double,char,double,double,double>::type answer;
|
|
BOOST_STATIC_ASSERT((<a href="../Reference/equal.html">equal</a>< result,answer >::type::value));
|
|
</pre>
|
|
<p>
|
|
<h3>See also</h3>
|
|
<p>
|
|
<a href="../Algorithms.html">Algorithms</a>, <code><a href="../Reference/replace_if.html">replace_if</a></code>, <code><a href="../Reference/transform.html">transform</a></code>
|
|
<p><hr>
|
|
<a href="../Table_of_Content.html">Table of Content</a> | <a href="../Reference.html">Reference</a><br>Last edited July 17, 2002 5:38 am</body></html> |