Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/mpl/doc/refmanual/transform.html @ 29

Last change on this file since 29 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 12.3 KB
Line 
1<?xml version="1.0" encoding="utf-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4<!-- Copyright Aleksey Gurtovoy 2006. Distributed under the Boost -->
5<!-- Software License, Version 1.0. (See accompanying -->
6<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
7<head>
8<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
10<title>The MPL Reference Manual: transform</title>
11<link rel="stylesheet" href="../style.css" type="text/css" />
12</head>
13<body class="docframe refmanual">
14<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./copy-if.html" class="navigation-link">Prev</a>&nbsp;<a href="./replace.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./copy-if.html" class="navigation-link">Back</a>&nbsp;<a href="./replace.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./transformation-algorithms.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
15<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./algorithms.html" class="navigation-link">Algorithms</a> / <a href="./transformation-algorithms.html" class="navigation-link">Transformation Algorithms</a> / <a href="./transform.html" class="navigation-link">transform</a></td>
16</tr></table><div class="header-separator"></div>
17<div class="section" id="transform">
18<h1><a class="toc-backref" href="./transformation-algorithms.html#id416" name="transform">transform</a></h1>
19<div class="section" id="transformation-transform-synopsis">
20<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
21<pre class="literal-block">
22template&lt;
23      typename Seq
24    , typename Op
25    , typename In = <em>unspecified</em>
26    &gt;
27struct <a href="./transform.html" class="identifier">transform</a>
28{
29    typedef <em>unspecified</em> type;
30};
31
32template&lt;
33      typename Seq1
34    , typename Seq2
35    , typename BinaryOp
36    , typename In = <em>unspecified</em>
37    &gt;
38struct <a href="./transform.html" class="identifier">transform</a>
39{
40    typedef <em>unspecified</em> type;
41};
42</pre>
43</div>
44<div class="section" id="transformation-transform-description">
45<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
46<p><tt class="literal"><span class="pre"><a href="./transform.html" class="identifier">transform</a></span></tt> is an <a class="reference" href="./terminology.html#overloaded-name">overloaded name</a>:</p>
47<ul class="simple">
48<li><tt class="literal"><span class="pre"><a href="./transform.html" class="identifier">transform</a>&lt;Seq,Op&gt;</span></tt> returns a transformed copy of the original sequence
49produced by applying an unary transformation <tt class="literal"><span class="pre">Op</span></tt> to every element
50in the [<tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a>&lt;Sequence&gt;::type</span></tt>, <tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a>&lt;Sequence&gt;::type</span></tt>) range.</li>
51<li><tt class="literal"><span class="pre"><a href="./transform.html" class="identifier">transform</a>&lt;Seq1,Seq2,Op&gt;</span></tt> returns a new sequence produced by applying a
52binary transformation <tt class="literal"><span class="pre">BinaryOp</span></tt> to a pair of elements (e<sub>1</sub>, e2<sub>1</sub>)
53from the corresponding [<tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a>&lt;Seq1&gt;::type</span></tt>, <tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a>&lt;Seq1&gt;::type</span></tt>) and [<tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a>&lt;Seq2&gt;::type</span></tt>, <tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a>&lt;Seq2&gt;::type</span></tt>) ranges.</li>
54</ul>
55<p>[<em>Note:</em> This wording applies to a no-inserter version(s) of the algorithm. See the
56<cite>Expression semantics</cite> subsection for a precise specification of the algorithm's
57details in all cases — <em>end note</em>]</p>
58</div>
59<div class="section" id="transformation-transform-header">
60<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
61<pre class="literal-block">
62#include &lt;<a href="../../../../boost/mpl/transform.hpp" class="header">boost/mpl/transform.hpp</a>&gt;
63</pre>
64</div>
65<div class="section" id="transformation-transform-model-of">
66<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
67<p><a class="reference" href="./reversible-algorithm.html">Reversible Algorithm</a></p>
68</div>
69<div class="section" id="transformation-transform-parameters">
70<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
71<table border="1" class="table">
72<colgroup>
73<col width="21%" />
74<col width="39%" />
75<col width="39%" />
76</colgroup>
77<thead valign="bottom">
78<tr><th>Parameter</th>
79<th>Requirement</th>
80<th>Description</th>
81</tr>
82</thead>
83<tbody valign="top">
84<tr><td><tt class="literal"><span class="pre">Sequence</span></tt>,
85<tt class="literal"><span class="pre">Seq1</span></tt>, <tt class="literal"><span class="pre">Seq2</span></tt></td>
86<td><a class="reference" href="./forward-sequence.html">Forward Sequence</a></td>
87<td>Sequences to transform.</td>
88</tr>
89<tr><td><tt class="literal"><span class="pre">Op</span></tt>,
90<tt class="literal"><span class="pre">BinaryOp</span></tt></td>
91<td><a class="reference" href="./lambda-expression.html">Lambda Expression</a></td>
92<td>A transformation.</td>
93</tr>
94<tr><td><tt class="literal"><span class="pre">In</span></tt></td>
95<td><a class="reference" href="./inserter.html">Inserter</a></td>
96<td>An inserter.</td>
97</tr>
98</tbody>
99</table>
100</div>
101<div class="section" id="transformation-transform-expression-semantics">
102<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
103<p>The semantics of an expression are defined only
104where they differ from, or are not defined in <a class="reference" href="./reversible-algorithm.html">Reversible Algorithm</a>.</p>
105<p>For any <a class="reference" href="./forward-sequence.html">Forward Sequence</a>s <tt class="literal"><span class="pre">s</span></tt>, <tt class="literal"><span class="pre">s1</span></tt> and <tt class="literal"><span class="pre">s2</span></tt>, <a class="reference" href="./lambda-expression.html">Lambda Expression</a>s <tt class="literal"><span class="pre">op</span></tt> and <tt class="literal"><span class="pre">op2</span></tt>,
106and an <a class="reference" href="./inserter.html">Inserter</a> <tt class="literal"><span class="pre">in</span></tt>:</p>
107<pre class="literal-block">
108typedef <a href="./transform.html" class="identifier">transform</a>&lt;s,op,in&gt;::type r;
109</pre>
110<table class="field-list" frame="void" rules="none">
111<col class="field-name" />
112<col class="field-body" />
113<tbody valign="top">
114<tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td>
115</tr>
116<tr class="field"><th class="field-name">Postcondition:</th><td class="field-body"><p class="first">Equivalent to</p>
117<pre class="last literal-block">
118typedef <a href="./lambda.html" class="identifier">lambda</a>&lt;op&gt;::type f;
119typedef <a href="./lambda.html" class="identifier">lambda</a>&lt;in::operation&gt;::type in_op;
120
121typedef <a href="./fold.html" class="identifier">fold</a>&lt; 
122      s
123    , in::state
124    , <a href="./bind.html" class="identifier">bind</a>&lt; in_op, _1, <a href="./bind.html" class="identifier">bind</a>&lt;f, _2&gt; &gt; 
125    &gt;::type r;
126</pre>
127</td>
128</tr>
129</tbody>
130</table>
131<pre class="literal-block">
132typedef <a href="./transform.html" class="identifier">transform</a>&lt;s1,s2,op,in&gt;::type r;
133</pre>
134<table class="field-list" frame="void" rules="none">
135<col class="field-name" />
136<col class="field-body" />
137<tbody valign="top">
138<tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td>
139</tr>
140<tr class="field"><th class="field-name">Postcondition:</th><td class="field-body"><p class="first">Equivalent to</p>
141<pre class="last literal-block">
142typedef <a href="./lambda.html" class="identifier">lambda</a>&lt;op2&gt;::type f;
143typedef <a href="./lambda.html" class="identifier">lambda</a>&lt;in::operation&gt;::type in_op;
144
145typedef <a href="./fold.html" class="identifier">fold</a>&lt; 
146      pair_view&lt;s1,s2&gt;
147    , in::state
148    , <a href="./bind.html" class="identifier">bind</a>&lt; 
149          in_op
150        , _1
151        , <a href="./bind.html" class="identifier">bind</a>&lt;f, <a href="./bind.html" class="identifier">bind</a>&lt;first&lt;&gt;,_2&gt;, <a href="./bind.html" class="identifier">bind</a>&lt;second&lt;&gt;,_2&gt; &gt;
152        &gt; 
153    &gt;::type r;
154</pre>
155</td>
156</tr>
157</tbody>
158</table>
159</div>
160<div class="section" id="transform-complexity">
161<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
162<p>Linear. Exactly <tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::value</span></tt> / <tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s1&gt;::value</span></tt> applications of
163<tt class="literal"><span class="pre">op</span></tt> / <tt class="literal"><span class="pre">op2</span></tt> and <tt class="literal"><span class="pre">in::operation</span></tt>.</p>
164</div>
165<div class="section" id="transformation-transform-example">
166<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
167<pre class="literal-block">
168typedef <a href="./vector.html" class="identifier">vector</a>&lt;char,short,int,long,float,double&gt; types;
169typedef <a href="./vector.html" class="identifier">vector</a>&lt;char*,short*,int*,long*,float*,double*&gt; pointers;
170typedef <a href="./transform.html" class="identifier">transform</a>&lt; types,boost::add_pointer&lt;_1&gt; &gt;::type result;
171
172<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( <a href="./equal.html" class="identifier">equal</a>&lt;result,pointers&gt; ));
173</pre>
174</div>
175<div class="section" id="transformation-transform-see-also">
176<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
177<p><a class="reference" href="./transformation-algorithms.html">Transformation Algorithms</a>, <a class="reference" href="./reversible-algorithm.html">Reversible Algorithm</a>, <a class="refentry reference" href="./reverse-transform.html"><tt class="refentry literal"><span class="pre">reverse_transform</span></tt></a>, <a class="refentry reference" href="./copy.html"><tt class="refentry literal"><span class="pre">copy</span></tt></a>, <a class="refentry reference" href="./replace-if.html"><tt class="refentry literal"><span class="pre">replace_if</span></tt></a></p>
178<!-- modtime: November 10, 2004 04:31:13 +0000 -->
179<!-- Algorithms/Transformation Algorithms//replace |40 -->
180</div>
181</div>
182
183<div class="footer-separator"></div>
184<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./copy-if.html" class="navigation-link">Prev</a>&nbsp;<a href="./replace.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./copy-if.html" class="navigation-link">Back</a>&nbsp;<a href="./replace.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./transformation-algorithms.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
185</tr></table></body>
186</html>
Note: See TracBrowser for help on using the repository browser.