1 | /*=============================================================================
|
---|
2 | Copyright (c) 2003 Joel de Guzman
|
---|
3 | Copyright (c) 2004 Peder Holt
|
---|
4 |
|
---|
5 | Use, modification and distribution is subject to the Boost Software
|
---|
6 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
7 | http://www.boost.org/LICENSE_1_0.txt)
|
---|
8 | ==============================================================================*/
|
---|
9 | #if !defined(FUSION_ALGORITHM_FIND_IF_HPP)
|
---|
10 | #define FUSION_ALGORITHM_FIND_IF_HPP
|
---|
11 |
|
---|
12 | #include <boost/spirit/fusion/algorithm/detail/find_if.ipp>
|
---|
13 | #include <boost/spirit/fusion/sequence/begin.hpp>
|
---|
14 | #include <boost/spirit/fusion/sequence/end.hpp>
|
---|
15 |
|
---|
16 | namespace boost { namespace fusion
|
---|
17 | {
|
---|
18 | namespace meta
|
---|
19 | {
|
---|
20 | template <typename Sequence, typename Pred>
|
---|
21 | struct find_if
|
---|
22 | {
|
---|
23 | typedef typename
|
---|
24 | detail::static_find_if<
|
---|
25 | typename meta::begin<Sequence>::type
|
---|
26 | , typename meta::end<Sequence>::type
|
---|
27 | , Pred
|
---|
28 | >::type
|
---|
29 | type;
|
---|
30 | };
|
---|
31 | }
|
---|
32 |
|
---|
33 | namespace function
|
---|
34 | {
|
---|
35 | struct find_if
|
---|
36 | {
|
---|
37 | template <typename Sequence, typename Pred>
|
---|
38 | struct apply : meta::find_if<Sequence, Pred> {};
|
---|
39 |
|
---|
40 | template <typename Sequence, typename Pred>
|
---|
41 | inline typename apply<Sequence const, Pred>::type
|
---|
42 | operator()(Sequence const& seq, Pred) const
|
---|
43 | {
|
---|
44 | typedef
|
---|
45 | detail::static_find_if<
|
---|
46 | BOOST_DEDUCED_TYPENAME meta::begin<Sequence const>::type
|
---|
47 | , BOOST_DEDUCED_TYPENAME meta::end<Sequence const>::type
|
---|
48 | , Pred
|
---|
49 | >
|
---|
50 | filter;
|
---|
51 |
|
---|
52 | return filter::call(fusion::begin(seq));
|
---|
53 | }
|
---|
54 |
|
---|
55 | template <typename Sequence, typename Pred>
|
---|
56 | inline typename apply<Sequence, Pred>::type
|
---|
57 | operator()(Sequence& seq, Pred) const
|
---|
58 | {
|
---|
59 | typedef
|
---|
60 | detail::static_find_if<
|
---|
61 | BOOST_DEDUCED_TYPENAME meta::begin<Sequence>::type
|
---|
62 | , BOOST_DEDUCED_TYPENAME meta::end<Sequence>::type
|
---|
63 | , Pred
|
---|
64 | >
|
---|
65 | filter;
|
---|
66 |
|
---|
67 | return filter::call(fusion::begin(seq));
|
---|
68 | }
|
---|
69 | };
|
---|
70 | }
|
---|
71 |
|
---|
72 | function::find_if const find_if = function::find_if();
|
---|
73 | }}
|
---|
74 |
|
---|
75 | #endif
|
---|
76 |
|
---|