| 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: reverse_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="./reverse-copy-if.html" class="navigation-link">Prev</a> <a href="./reverse-replace.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./reverse-copy-if.html" class="navigation-link">Back</a> <a href="./reverse-replace.html" class="navigation-link">Along</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./transformation-algorithms.html" class="navigation-link">Up</a> <a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator"> | </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="./reverse-transform.html" class="navigation-link">reverse_transform</a></td> |
|---|
| 16 | </tr></table><div class="header-separator"></div> |
|---|
| 17 | <div class="section" id="reverse-transform"> |
|---|
| 18 | <h1><a class="toc-backref" href="./transformation-algorithms.html#id428" name="reverse-transform">reverse_transform</a></h1> |
|---|
| 19 | <div class="section" id="id122"> |
|---|
| 20 | <h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3> |
|---|
| 21 | <pre class="literal-block"> |
|---|
| 22 | template< |
|---|
| 23 | typename Seq |
|---|
| 24 | , typename Op |
|---|
| 25 | , typename In = <em>unspecified</em> |
|---|
| 26 | > |
|---|
| 27 | struct <a href="./reverse-transform.html" class="identifier">reverse_transform</a> |
|---|
| 28 | { |
|---|
| 29 | typedef <em>unspecified</em> type; |
|---|
| 30 | }; |
|---|
| 31 | |
|---|
| 32 | template< |
|---|
| 33 | typename Seq1 |
|---|
| 34 | , typename Seq2 |
|---|
| 35 | , typename BinaryOp |
|---|
| 36 | , typename In = <em>unspecified</em> |
|---|
| 37 | > |
|---|
| 38 | struct <a href="./reverse-transform.html" class="identifier">reverse_transform</a> |
|---|
| 39 | { |
|---|
| 40 | typedef <em>unspecified</em> type; |
|---|
| 41 | }; |
|---|
| 42 | </pre> |
|---|
| 43 | </div> |
|---|
| 44 | <div class="section" id="id123"> |
|---|
| 45 | <h3><a class="subsection-title" href="#description" name="description">Description</a></h3> |
|---|
| 46 | <p><tt class="literal"><span class="pre"><a href="./reverse-transform.html" class="identifier">reverse_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="./reverse-transform.html" class="identifier">reverse_transform</a><Seq,Op></span></tt> returns a reversed, transformed copy of the |
|---|
| 49 | original sequence produced by applying an unary transformation <tt class="literal"><span class="pre">Op</span></tt> to |
|---|
| 50 | every element in the [<tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a><Sequence>::type</span></tt>, <tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a><Sequence>::type</span></tt>) range.</li> |
|---|
| 51 | <li><tt class="literal"><span class="pre"><a href="./reverse-transform.html" class="identifier">reverse_transform</a><Seq1,Seq2,Op></span></tt> returns a new sequence produced by applying a |
|---|
| 52 | binary transformation <tt class="literal"><span class="pre">BinaryOp</span></tt> to a pair of elements (e<sub>1</sub>, e2<sub>1</sub>) |
|---|
| 53 | from the corresponding [<tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a><Seq1>::type</span></tt>, <tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a><Seq1>::type</span></tt>) and [<tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a><Seq2>::type</span></tt>, <tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a><Seq2>::type</span></tt>) ranges in reverse |
|---|
| 54 | order.</li> |
|---|
| 55 | </ul> |
|---|
| 56 | <p>[<em>Note:</em> This wording applies to a no-inserter version(s) of the algorithm. See the |
|---|
| 57 | <cite>Expression semantics</cite> subsection for a precise specification of the algorithm's |
|---|
| 58 | details in all cases — <em>end note</em>]</p> |
|---|
| 59 | </div> |
|---|
| 60 | <div class="section" id="id124"> |
|---|
| 61 | <h3><a class="subsection-title" href="#header" name="header">Header</a></h3> |
|---|
| 62 | <pre class="literal-block"> |
|---|
| 63 | #include <<a href="../../../../boost/mpl/transform.hpp" class="header">boost/mpl/transform.hpp</a>> |
|---|
| 64 | </pre> |
|---|
| 65 | </div> |
|---|
| 66 | <div class="section" id="algorithms-transformation-reverse-model-of"> |
|---|
| 67 | <h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3> |
|---|
| 68 | <p><a class="reference" href="./reversible-algorithm.html">Reversible Algorithm</a></p> |
|---|
| 69 | </div> |
|---|
| 70 | <div class="section" id="id125"> |
|---|
| 71 | <h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3> |
|---|
| 72 | <table border="1" class="table"> |
|---|
| 73 | <colgroup> |
|---|
| 74 | <col width="21%" /> |
|---|
| 75 | <col width="39%" /> |
|---|
| 76 | <col width="39%" /> |
|---|
| 77 | </colgroup> |
|---|
| 78 | <thead valign="bottom"> |
|---|
| 79 | <tr><th>Parameter</th> |
|---|
| 80 | <th>Requirement</th> |
|---|
| 81 | <th>Description</th> |
|---|
| 82 | </tr> |
|---|
| 83 | </thead> |
|---|
| 84 | <tbody valign="top"> |
|---|
| 85 | <tr><td><tt class="literal"><span class="pre">Sequence</span></tt>, |
|---|
| 86 | <tt class="literal"><span class="pre">Seq1</span></tt>, <tt class="literal"><span class="pre">Seq2</span></tt></td> |
|---|
| 87 | <td><a class="reference" href="./forward-sequence.html">Forward Sequence</a></td> |
|---|
| 88 | <td>Sequences to transform.</td> |
|---|
| 89 | </tr> |
|---|
| 90 | <tr><td><tt class="literal"><span class="pre">Op</span></tt>, |
|---|
| 91 | <tt class="literal"><span class="pre">BinaryOp</span></tt></td> |
|---|
| 92 | <td><a class="reference" href="./lambda-expression.html">Lambda Expression</a></td> |
|---|
| 93 | <td>A transformation.</td> |
|---|
| 94 | </tr> |
|---|
| 95 | <tr><td><tt class="literal"><span class="pre">In</span></tt></td> |
|---|
| 96 | <td><a class="reference" href="./inserter.html">Inserter</a></td> |
|---|
| 97 | <td>An inserter.</td> |
|---|
| 98 | </tr> |
|---|
| 99 | </tbody> |
|---|
| 100 | </table> |
|---|
| 101 | </div> |
|---|
| 102 | <div class="section" id="id126"> |
|---|
| 103 | <h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3> |
|---|
| 104 | <p>The semantics of an expression are defined only |
|---|
| 105 | where they differ from, or are not defined in <a class="reference" href="./reversible-algorithm.html">Reversible Algorithm</a>.</p> |
|---|
| 106 | <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>, |
|---|
| 107 | and an <a class="reference" href="./inserter.html">Inserter</a> <tt class="literal"><span class="pre">in</span></tt>:</p> |
|---|
| 108 | <pre class="literal-block"> |
|---|
| 109 | typedef <a href="./reverse-transform.html" class="identifier">reverse_transform</a><s,op,in>::type r; |
|---|
| 110 | </pre> |
|---|
| 111 | <table class="field-list" frame="void" rules="none"> |
|---|
| 112 | <col class="field-name" /> |
|---|
| 113 | <col class="field-body" /> |
|---|
| 114 | <tbody valign="top"> |
|---|
| 115 | <tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td> |
|---|
| 116 | </tr> |
|---|
| 117 | <tr class="field"><th class="field-name">Postcondition:</th><td class="field-body"><p class="first">Equivalent to</p> |
|---|
| 118 | <pre class="last literal-block"> |
|---|
| 119 | typedef <a href="./lambda.html" class="identifier">lambda</a><op>::type f; |
|---|
| 120 | typedef <a href="./lambda.html" class="identifier">lambda</a><in::operation>::type in_op; |
|---|
| 121 | |
|---|
| 122 | typedef <a href="./reverse-fold.html" class="identifier">reverse_fold</a>< |
|---|
| 123 | s |
|---|
| 124 | , in::state |
|---|
| 125 | , <a href="./bind.html" class="identifier">bind</a>< in_op, _1, <a href="./bind.html" class="identifier">bind</a><f, _2> > |
|---|
| 126 | >::type r; |
|---|
| 127 | </pre> |
|---|
| 128 | </td> |
|---|
| 129 | </tr> |
|---|
| 130 | </tbody> |
|---|
| 131 | </table> |
|---|
| 132 | <pre class="literal-block"> |
|---|
| 133 | typedef <a href="./transform.html" class="identifier">transform</a><s1,s2,op,in>::type r; |
|---|
| 134 | </pre> |
|---|
| 135 | <table class="field-list" frame="void" rules="none"> |
|---|
| 136 | <col class="field-name" /> |
|---|
| 137 | <col class="field-body" /> |
|---|
| 138 | <tbody valign="top"> |
|---|
| 139 | <tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td> |
|---|
| 140 | </tr> |
|---|
| 141 | <tr class="field"><th class="field-name">Postcondition:</th><td class="field-body"><p class="first">Equivalent to</p> |
|---|
| 142 | <pre class="last literal-block"> |
|---|
| 143 | typedef <a href="./lambda.html" class="identifier">lambda</a><op2>::type f; |
|---|
| 144 | typedef <a href="./lambda.html" class="identifier">lambda</a><in::operation>::type in_op; |
|---|
| 145 | |
|---|
| 146 | typedef <a href="./reverse-fold.html" class="identifier">reverse_fold</a>< |
|---|
| 147 | pair_view<s1,s2> |
|---|
| 148 | , in::state |
|---|
| 149 | , <a href="./bind.html" class="identifier">bind</a>< |
|---|
| 150 | in_op |
|---|
| 151 | , _1 |
|---|
| 152 | , <a href="./bind.html" class="identifier">bind</a><f, <a href="./bind.html" class="identifier">bind</a><first<>,_2>, <a href="./bind.html" class="identifier">bind</a><second<>,_2> > |
|---|
| 153 | > |
|---|
| 154 | >::type r; |
|---|
| 155 | </pre> |
|---|
| 156 | </td> |
|---|
| 157 | </tr> |
|---|
| 158 | </tbody> |
|---|
| 159 | </table> |
|---|
| 160 | </div> |
|---|
| 161 | <div class="section" id="id127"> |
|---|
| 162 | <h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3> |
|---|
| 163 | <p>Linear. Exactly <tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a><s>::value</span></tt> / <tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a><s1>::value</span></tt> applications of |
|---|
| 164 | <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> |
|---|
| 165 | </div> |
|---|
| 166 | <div class="section" id="id128"> |
|---|
| 167 | <h3><a class="subsection-title" href="#example" name="example">Example</a></h3> |
|---|
| 168 | <pre class="literal-block"> |
|---|
| 169 | typedef <a href="./vector.html" class="identifier">vector</a><char,short,int,long,float,double> types; |
|---|
| 170 | typedef <a href="./vector.html" class="identifier">vector</a><double*,float*,long*,int*,short*,char*> pointers; |
|---|
| 171 | typedef <a href="./reverse-transform.html" class="identifier">reverse_transform</a>< types,boost::add_pointer<_1> >::type result; |
|---|
| 172 | |
|---|
| 173 | <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( <a href="./equal.html" class="identifier">equal</a><result,pointers> )); |
|---|
| 174 | </pre> |
|---|
| 175 | </div> |
|---|
| 176 | <div class="section" id="id129"> |
|---|
| 177 | <h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3> |
|---|
| 178 | <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="./transform.html"><tt class="refentry literal"><span class="pre">transform</span></tt></a>, <a class="refentry reference" href="./reverse-copy.html"><tt class="refentry literal"><span class="pre">reverse_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> |
|---|
| 179 | <!-- modtime: November 10, 2004 04:32:21 +0000 --> |
|---|
| 180 | <!-- Algorithms/Transformation Algorithms//reverse_replace |140 --> |
|---|
| 181 | </div> |
|---|
| 182 | </div> |
|---|
| 183 | |
|---|
| 184 | <div class="footer-separator"></div> |
|---|
| 185 | <table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./reverse-copy-if.html" class="navigation-link">Prev</a> <a href="./reverse-replace.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./reverse-copy-if.html" class="navigation-link">Back</a> <a href="./reverse-replace.html" class="navigation-link">Along</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./transformation-algorithms.html" class="navigation-link">Up</a> <a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td> |
|---|
| 186 | </tr></table></body> |
|---|
| 187 | </html> |
|---|