1 | |
2 | #ifndef BOOST_MPL_COUNT_IF_HPP_INCLUDED |
3 | #define BOOST_MPL_COUNT_IF_HPP_INCLUDED |
4 | |
5 | // Copyright Aleksey Gurtovoy 2000-2002 |
6 | // |
7 | // Distributed under the Boost Software License, Version 1.0. |
8 | // (See accompanying file LICENSE_1_0.txt or copy at |
9 | // http://www.boost.org/LICENSE_1_0.txt) |
10 | // |
11 | // See http://www.boost.org/libs/mpl for documentation. |
12 | |
13 | // $Id$ |
14 | // $Date$ |
15 | // $Revision$ |
16 | |
17 | #include <boost/mpl/fold.hpp> |
18 | #include <boost/mpl/next.hpp> |
19 | #include <boost/mpl/integral_c.hpp> |
20 | #include <boost/mpl/identity.hpp> |
21 | #include <boost/mpl/eval_if.hpp> |
22 | #include <boost/mpl/apply.hpp> |
23 | #include <boost/mpl/aux_/msvc_eti_base.hpp> |
24 | #include <boost/mpl/aux_/na_spec.hpp> |
25 | #include <boost/mpl/aux_/lambda_support.hpp> |
26 | #include <boost/mpl/aux_/config/forwarding.hpp> |
27 | |
28 | namespace boost { namespace mpl { |
29 | |
30 | namespace aux { |
31 | |
32 | template< typename Predicate > |
33 | struct next_if |
34 | { |
35 | template< |
36 | typename N |
37 | , typename T |
38 | > |
39 | struct apply |
40 | #if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING) |
41 | : eval_if< |
42 | typename apply1<Predicate,T>::type |
43 | , next<N> |
44 | , identity<N> |
45 | > |
46 | { |
47 | #else |
48 | { |
49 | typedef typename eval_if< |
50 | typename apply1<Predicate,T>::type |
51 | , next<N> |
52 | , identity<N> |
53 | >::type type; |
54 | #endif |
55 | }; |
56 | }; |
57 | |
58 | } // namespace aux |
59 | |
60 | |
61 | template< |
62 | typename BOOST_MPL_AUX_NA_PARAM(Sequence) |
63 | , typename BOOST_MPL_AUX_NA_PARAM(Predicate) |
64 | > |
65 | struct count_if |
66 | : aux::msvc_eti_base< typename fold< |
67 | Sequence |
68 | , integral_c<unsigned long,0> |
69 | , protect< aux::next_if<Predicate> > |
70 | >::type > |
71 | { |
72 | BOOST_MPL_AUX_LAMBDA_SUPPORT(2,count_if,(Sequence,Predicate)) |
73 | }; |
74 | |
75 | BOOST_MPL_AUX_NA_SPEC(2, count_if) |
76 | |
77 | }} |
78 | |
79 | #endif // BOOST_MPL_COUNT_IF_HPP_INCLUDED |
80 | |