]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*============================================================================= |
2 | Copyright (c) 2001-2011 Joel de Guzman | |
3 | ||
4 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
5 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 | ==============================================================================*/ | |
7 | #if !defined(FUSION_NEXT_IMPL_06052005_0900) | |
8 | #define FUSION_NEXT_IMPL_06052005_0900 | |
9 | ||
10 | #include <boost/fusion/support/config.hpp> | |
11 | #include <boost/fusion/algorithm/query/detail/find_if.hpp> | |
12 | #include <boost/fusion/iterator/value_of.hpp> | |
13 | #include <boost/mpl/eval_if.hpp> | |
14 | #include <boost/mpl/identity.hpp> | |
15 | #include <boost/mpl/lambda.hpp> | |
16 | #include <boost/mpl/quote.hpp> | |
17 | #include <boost/mpl/bind.hpp> | |
18 | #include <boost/mpl/placeholders.hpp> | |
19 | ||
20 | namespace boost { namespace fusion | |
21 | { | |
22 | struct filter_view_iterator_tag; | |
23 | ||
24 | template <typename Category, typename First, typename Last, typename Pred> | |
25 | struct filter_iterator; | |
26 | ||
27 | namespace extension | |
28 | { | |
29 | template <typename Tag> | |
30 | struct next_impl; | |
31 | ||
32 | template <> | |
33 | struct next_impl<filter_view_iterator_tag> | |
34 | { | |
35 | template <typename Iterator> | |
36 | struct apply | |
37 | { | |
38 | typedef typename Iterator::first_type first_type; | |
39 | typedef typename Iterator::last_type last_type; | |
40 | typedef typename Iterator::pred_type pred_type; | |
41 | typedef typename Iterator::category category; | |
42 | ||
43 | typedef typename | |
44 | mpl::eval_if< | |
45 | result_of::equal_to<first_type, last_type> | |
46 | , mpl::identity<last_type> | |
47 | , result_of::next<first_type> | |
48 | >::type | |
49 | next_type; | |
50 | ||
51 | typedef typename | |
52 | detail::static_find_if< | |
53 | next_type | |
54 | , last_type | |
55 | , mpl::bind1< | |
56 | typename mpl::lambda<pred_type>::type | |
57 | , mpl::bind1<mpl::quote1<result_of::value_of>,mpl::_1> | |
58 | > | |
59 | > | |
60 | filter; | |
61 | ||
62 | typedef filter_iterator< | |
63 | category, typename filter::type, last_type, pred_type> | |
64 | type; | |
65 | ||
66 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
67 | static type | |
68 | call(Iterator const& i) | |
69 | { | |
70 | return type(filter::iter_call(i.first)); | |
71 | } | |
72 | }; | |
73 | }; | |
74 | } | |
75 | }} | |
76 | ||
77 | #endif | |
78 | ||
79 |