]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mpl/doc/src/refmanual/replace_if.rst
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / mpl / doc / src / refmanual / replace_if.rst
1 .. Algorithms/Transformation Algorithms//replace_if |50
2
3 replace_if
4 ==========
5
6 Synopsis
7 --------
8
9 .. parsed-literal::
10
11 template<
12 typename Sequence
13 , typename Pred
14 , typename NewType
15 , typename In = |unspecified|
16 >
17 struct replace_if
18 {
19 typedef |unspecified| type;
20 };
21
22
23
24 Description
25 -----------
26
27 Returns a copy of the original sequence where every type that satisfies
28 the predicate ``Pred`` has been replaced with ``NewType``.
29
30 |transformation algorithm disclaimer|
31
32 Header
33 ------
34
35 .. parsed-literal::
36
37 #include <boost/mpl/replace_if.hpp>
38
39
40
41 Model of
42 --------
43
44 |Reversible Algorithm|
45
46
47 Parameters
48 ----------
49
50 +---------------+-----------------------------------+-------------------------------+
51 | Parameter | Requirement | Description |
52 +===============+===================================+===============================+
53 | ``Sequence`` | |Forward Sequence| | An original sequence. |
54 +---------------+-----------------------------------+-------------------------------+
55 | ``Pred`` | Unary |Lambda Expression| | A replacement condition. |
56 +---------------+-----------------------------------+-------------------------------+
57 | ``NewType`` | Any type | A type to replace with. |
58 +---------------+-----------------------------------+-------------------------------+
59 | ``In`` | |Inserter| | An inserter. |
60 +---------------+-----------------------------------+-------------------------------+
61
62
63 Expression semantics
64 --------------------
65
66 |Semantics disclaimer...| |Reversible Algorithm|.
67
68 For any |Forward Sequence| ``s``, an unary |Lambda Expression| ``pred``,
69 an |Inserter| ``in``, and arbitrary type ``x``:
70
71
72 .. parsed-literal::
73
74 typedef replace_if<s,pred,x,in>::type r;
75
76 :Return type:
77 A type.
78
79 :Semantics:
80 Equivalent to
81
82 .. parsed-literal::
83
84 typedef lambda<pred>::type p;
85 typedef transform< s, if_< apply_wrap1<p,_1>,x,_1>, in >::type r;
86
87
88 Complexity
89 ----------
90
91 Linear. Performs exactly ``size<s>::value`` applications of ``pred``, and at most
92 ``size<s>::value`` insertions.
93
94
95 Example
96 -------
97
98 .. parsed-literal::
99
100 typedef vector_c<int,1,4,5,2,7,5,3,5> numbers;
101 typedef vector_c<int,1,4,0,2,0,0,3,0> expected;
102 typedef replace_if< numbers, greater<_,int_<4> >, int_<0> >::type result;
103
104 BOOST_MPL_ASSERT(( equal< result,expected, equal_to<_,_> > ));
105
106
107 See also
108 --------
109
110 |Transformation Algorithms|, |Reversible Algorithm|, |reverse_replace_if|, |replace|, |remove_if|, |transform|
111
112
113 .. copyright:: Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams
114 Distributed under the Boost Software License, Version 1.0. (See accompanying
115 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)