]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Algorithms/Transformation Algorithms//reverse_copy_if |120 |
2 | ||
3 | reverse_copy_if | |
4 | =============== | |
5 | ||
6 | Synopsis | |
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 | ||
23 | Description | |
24 | ----------- | |
25 | ||
26 | Returns a reversed, filtered copy of the original sequence containing the | |
27 | elements that satisfy the predicate ``Pred``. | |
28 | ||
29 | |transformation algorithm disclaimer| | |
30 | ||
31 | Header | |
32 | ------ | |
33 | ||
34 | .. parsed-literal:: | |
35 | ||
36 | #include <boost/mpl/copy_if.hpp> | |
37 | ||
38 | ||
39 | Model of | |
40 | -------- | |
41 | ||
42 | |Reversible Algorithm| | |
43 | ||
44 | ||
45 | Parameters | |
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 | ||
59 | Expression semantics | |
60 | -------------------- | |
61 | ||
62 | |Semantics disclaimer...| |Reversible Algorithm|. | |
63 | ||
64 | For any |Forward Sequence| ``s``, an unary |Lambda Expression| ``pred``, and | |
65 | an |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 | ||
95 | Complexity | |
96 | ---------- | |
97 | ||
98 | Linear. Exactly ``size<s>::value`` applications of ``pred``, and at | |
99 | most ``size<s>::value`` applications of ``in::operation``. | |
100 | ||
101 | ||
102 | Example | |
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 | ||
117 | See also | |
118 | -------- | |
119 | ||
120 | |Transformation Algorithms|, |Reversible Algorithm|, |copy_if|, |reverse_copy|, |remove_if|, |replace_if| | |
121 | ||
122 | ||
123 |