• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. Algorithms/Transformation Algorithms//reverse_transform |130
2
3reverse_transform
4=================
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11    template<
12          typename Seq
13        , typename Op
14        , typename In = |unspecified|
15        >
16    struct reverse_transform
17    {
18        typedef |unspecified| type;
19    };
20
21    template<
22          typename Seq1
23        , typename Seq2
24        , typename BinaryOp
25        , typename In = |unspecified|
26        >
27    struct reverse_transform
28    {
29        typedef |unspecified| type;
30    };
31
32
33Description
34-----------
35
36``reverse_transform`` is an |overloaded name|:
37
38* ``reverse_transform<Seq,Op>`` returns a reversed, transformed copy of the
39  original sequence produced by applying an unary transformation ``Op`` to
40  every element in the |begin/end<Sequence>| range.
41
42* ``reverse_transform<Seq1,Seq2,Op>`` returns a new sequence produced by applying a
43  binary transformation ``BinaryOp`` to a pair of elements (e\ :sub:`1`, e2\ :sub:`1`)
44  from the corresponding |begin/end<Seq1>| and |begin/end<Seq2>| ranges in reverse
45  order.
46
47|transformation algorithm disclaimer|
48
49
50Header
51------
52
53.. parsed-literal::
54
55    #include <boost/mpl/transform.hpp>
56
57
58Model of
59--------
60
61|Reversible Algorithm|
62
63
64Parameters
65----------
66
67+-------------------+-----------------------------------+-----------------------------------+
68| Parameter         | Requirement                       | Description                       |
69+===================+===================================+===================================+
70| ``Sequence``,     | |Forward Sequence|                | Sequences to transform.           |
71| ``Seq1``, ``Seq2``|                                   |                                   |
72+-------------------+-----------------------------------+-----------------------------------+
73| ``Op``,           | |Lambda Expression|               | A transformation.                 |
74| ``BinaryOp``      |                                   |                                   |
75+-------------------+-----------------------------------+-----------------------------------+
76| ``In``            | |Inserter|                        | An inserter.                      |
77+-------------------+-----------------------------------+-----------------------------------+
78
79
80Expression semantics
81--------------------
82
83|Semantics disclaimer...| |Reversible Algorithm|.
84
85For any |Forward Sequence|\ s ``s``, ``s1`` and ``s2``, |Lambda Expression|\ s ``op`` and ``op2``,
86and an |Inserter| ``in``:
87
88.. parsed-literal::
89
90    typedef reverse_transform<s,op,in>::type r;
91
92:Return type:
93    A type.
94
95:Postcondition:
96    Equivalent to
97
98    .. parsed-literal::
99
100        typedef lambda<op>::type f;
101        typedef lambda<in::operation>::type in_op;
102
103        typedef reverse_fold<
104              s
105            , in::state
106            , bind< in_op, _1, bind<f, _2> >
107            >::type r;
108
109
110.. parsed-literal::
111
112    typedef transform<s1,s2,op,in>::type r;
113
114:Return type:
115    A type.
116
117:Postcondition:
118    Equivalent to
119
120    .. parsed-literal::
121
122        typedef lambda<op2>::type f;
123        typedef lambda<in::operation>::type in_op;
124
125        typedef reverse_fold<
126              pair_view<s1,s2>
127            , in::state
128            , bind<
129                  in_op
130                , _1
131                , bind<f, bind<first<>,_2>, bind<second<>,_2> >
132                >
133            >::type r;
134
135
136Complexity
137----------
138
139Linear. Exactly ``size<s>::value`` / ``size<s1>::value`` applications of
140``op`` / ``op2`` and ``in::operation``.
141
142
143Example
144-------
145
146.. parsed-literal::
147
148    typedef vector<char,short,int,long,float,double> types;
149    typedef vector<double*,float*,long*,int*,short*,char*> pointers;
150    typedef reverse_transform< types,boost::add_pointer<_1> >::type result;
151
152    BOOST_MPL_ASSERT(( equal<result,pointers> ));
153
154
155See also
156--------
157
158|Transformation Algorithms|, |Reversible Algorithm|, |transform|, |reverse_copy|, |replace_if|
159
160
161.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
162   Distributed under the Boost Software License, Version 1.0. (See accompanying
163   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
164