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_ITERATOR_FILTER_VIEW_ITERATOR_HPP)
|
---|
10 | #define FUSION_ITERATOR_FILTER_VIEW_ITERATOR_HPP
|
---|
11 |
|
---|
12 | #include <boost/spirit/fusion/iterator/as_fusion_iterator.hpp>
|
---|
13 | #include <boost/spirit/fusion/iterator/detail/iterator_base.hpp>
|
---|
14 | #include <boost/spirit/fusion/iterator/detail/filter_view_iterator/deref_traits.hpp>
|
---|
15 | #include <boost/spirit/fusion/iterator/detail/filter_view_iterator/next_traits.hpp>
|
---|
16 | #include <boost/spirit/fusion/iterator/detail/filter_view_iterator/value_traits.hpp>
|
---|
17 | #include <boost/spirit/fusion/algorithm/detail/find_if.ipp>
|
---|
18 |
|
---|
19 | namespace boost { namespace fusion
|
---|
20 | {
|
---|
21 | struct filter_view_iterator_tag;
|
---|
22 |
|
---|
23 | template <typename First, typename Last, typename Pred>
|
---|
24 | struct filter_iterator : iterator_base<filter_iterator<First, Last, Pred> >
|
---|
25 | {
|
---|
26 | typedef as_fusion_iterator<First> first_converter;
|
---|
27 | typedef typename first_converter::type first_iter;
|
---|
28 | typedef as_fusion_iterator<Last> last_converter;
|
---|
29 | typedef typename last_converter::type last_iter;
|
---|
30 |
|
---|
31 | typedef filter_view_iterator_tag tag;
|
---|
32 | typedef detail::static_find_if<first_iter, last_iter, Pred> filter;
|
---|
33 | typedef typename filter::type first_type;
|
---|
34 | typedef last_iter last_type;
|
---|
35 | typedef Pred pred_type;
|
---|
36 |
|
---|
37 | filter_iterator(First const& first);
|
---|
38 |
|
---|
39 | first_type first;
|
---|
40 | };
|
---|
41 |
|
---|
42 | template <typename First, typename Last, typename Pred>
|
---|
43 | filter_iterator<First,Last,Pred>::filter_iterator(First const& first)
|
---|
44 | : first(filter::call(first_converter::convert(first)))
|
---|
45 | {}
|
---|
46 | }}
|
---|
47 |
|
---|
48 | #endif
|
---|
49 |
|
---|
50 |
|
---|