1 .. Algorithms/Querying Algorithms//count_if |50
17 typedef |unspecified| type;
25 Returns the number of elements in ``Sequence`` that satisfy the predicate ``Pred``.
33 #include <boost/mpl/count_if.hpp>
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 +---------------+-------------------------------+-----------------------------------+
53 For any |Forward Sequence| ``s`` and unary |Lambda Expression| ``pred``:
57 typedef count_if<s,pred>::type n;
67 typedef lambda<pred>::type p;
71 , if_< apply_wrap\ ``1``\<p,_2>, next<_1>, _1 >
78 Linear. Exactly ``size<s>::value`` applications of ``pred``.
86 typedef vector<int,char,long,short,char,long,double,long> types;
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 );
96 |Querying Algorithms|, |count|, |find|, |find_if|, |contains|
99 .. copyright:: Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams
100 Distributed under the Boost Software License, Version 1.0. (See accompanying
101 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)