• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. Algorithms/Transformation Algorithms//reverse_copy_if |120
2
3reverse_copy_if
4===============
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11    template<
12          typename Sequence
13        , typename Pred
14        , typename In = |unspecified|
15        >
16    struct reverse_copy_if
17    {
18        typedef |unspecified| type;
19    };
20
21
22
23Description
24-----------
25
26Returns a reversed, filtered copy of the original sequence containing the
27elements that satisfy the predicate ``Pred``.
28
29|transformation algorithm disclaimer|
30
31Header
32------
33
34.. parsed-literal::
35
36    #include <boost/mpl/copy_if.hpp>
37
38
39Model of
40--------
41
42|Reversible Algorithm|
43
44
45Parameters
46----------
47
48+---------------+-----------------------------------+-------------------------------+
49| Parameter     | Requirement                       | Description                   |
50+===============+===================================+===============================+
51| ``Sequence``  | |Forward Sequence|                | A sequence to copy.           |
52+---------------+-----------------------------------+-------------------------------+
53| ``Pred``      | Unary |Lambda Expression|         | A copying condition.          |
54+---------------+-----------------------------------+-------------------------------+
55| ``In``        | |Inserter|                        | An inserter.                  |
56+---------------+-----------------------------------+-------------------------------+
57
58
59Expression semantics
60--------------------
61
62|Semantics disclaimer...| |Reversible Algorithm|.
63
64For any |Forward Sequence| ``s``, an unary |Lambda Expression| ``pred``, and
65an |Inserter| ``in``:
66
67
68.. parsed-literal::
69
70    typedef reverse_copy_if<s,pred,in>::type r;
71
72
73:Return type:
74    A type
75
76:Semantics:
77    Equivalent to
78
79    .. parsed-literal::
80
81        typedef lambda<pred>::type p;
82        typedef lambda<in::operation>::type op;
83
84        typedef reverse_fold<
85              s
86            , in::state
87            , eval_if<
88                  apply_wrap\ ``1``\<p,_2>
89                , apply_wrap\ ``2``\<op,_1,_2>
90                , identity<_1>
91                >
92            >::type r;
93
94
95Complexity
96----------
97
98Linear. Exactly ``size<s>::value`` applications of ``pred``, and at
99most ``size<s>::value`` applications of ``in::operation``.
100
101
102Example
103-------
104
105.. parsed-literal::
106
107    typedef reverse_copy_if<
108          range_c<int,0,10>
109        , less< _1, int_<5> >
110        , front_inserter< vector<> >
111        >::type result;
112
113    BOOST_MPL_ASSERT_RELATION( size<result>::value, ==, 5 );
114    BOOST_MPL_ASSERT(( equal<result,range_c<int,0,5> > ));
115
116
117See also
118--------
119
120|Transformation Algorithms|, |Reversible Algorithm|, |copy_if|, |reverse_copy|, |remove_if|, |replace_if|
121
122
123.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
124   Distributed under the Boost Software License, Version 1.0. (See accompanying
125   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
126