]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mpl/doc/src/refmanual/copy_if.rst
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / mpl / doc / src / refmanual / copy_if.rst
1 .. Algorithms/Transformation Algorithms//copy_if |20
2
3 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 copy_if
17 {
18 typedef |unspecified| type;
19 };
20
21
22
23 Description
24 -----------
25
26 Returns a filtered copy of the original sequence containing the elements that satisfy
27 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 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 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 copy_if<
108 range_c<int,0,10>
109 , less< _1, int_<5> >
110 , back_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|, |reverse_copy_if|, |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)