]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/mpl/doc/src/refmanual/count_if.rst
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / mpl / doc / src / refmanual / count_if.rst
CommitLineData
7c673cae
FG
1.. Algorithms/Querying Algorithms//count_if |50
2
3count_if
4========
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11 template<
12 typename Sequence
13 , typename Pred
14 >
15 struct count_if
16 {
17 typedef |unspecified| type;
18 };
19
20
21
22Description
23-----------
24
25Returns the number of elements in ``Sequence`` that satisfy the predicate ``Pred``.
26
27
28Header
29------
30
31.. parsed-literal::
32
33 #include <boost/mpl/count_if.hpp>
34
35
36
37Parameters
38----------
39
40+---------------+-------------------------------+-----------------------------------+
41| Parameter | Requirement | Description |
42+===============+===============================+===================================+
43| ``Sequence`` | |Forward Sequence| | A sequence to be examined. |
44+---------------+-------------------------------+-----------------------------------+
45| ``Pred`` | Unary |Lambda Expression| | A count condition. |
46+---------------+-------------------------------+-----------------------------------+
47
48
49Expression semantics
50--------------------
51
52
53For any |Forward Sequence| ``s`` and unary |Lambda Expression| ``pred``:
54
55.. parsed-literal::
56
57 typedef count_if<s,pred>::type n;
58
59:Return type:
60 |Integral Constant|.
61
62:Semantics:
63 Equivalent to
64
65 .. parsed-literal::
66
67 typedef lambda<pred>::type p;
68 typedef fold<
69 s
70 , long_<0>
71 , if_< apply_wrap\ ``1``\<p,_2>, next<_1>, _1 >
72 >::type n;
73
74
75Complexity
76----------
77
78Linear. Exactly ``size<s>::value`` applications of ``pred``.
79
80
81Example
82-------
83
84.. parsed-literal::
85
86 typedef vector<int,char,long,short,char,long,double,long> types;
87
88 BOOST_MPL_ASSERT_RELATION( (count_if< types, is_float<_> >::value), ==, 1 );
89 BOOST_MPL_ASSERT_RELATION( (count_if< types, is_same<_,char> >::value), ==, 2 );
90 BOOST_MPL_ASSERT_RELATION( (count_if< types, is_same<_,void> >::value), ==, 0 );
91
92
93See also
94--------
95
96|Querying Algorithms|, |count|, |find|, |find_if|, |contains|
97
98
99