source: NonGTP/Boost/boost/spirit/fusion/iterator/detail/filter_view_iterator/next_traits.hpp @ 857

Revision 857, 2.4 KB checked in by igarcia, 18 years ago (diff)
Line 
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_DETAIL_FILTER_VIEW_ITERATOR_NEXT_TRAITS_HPP)
10#define FUSION_ITERATOR_DETAIL_FILTER_VIEW_ITERATOR_NEXT_TRAITS_HPP
11
12#include <boost/spirit/fusion/detail/config.hpp>
13#include <boost/spirit/fusion/algorithm/detail/find_if.ipp>
14#include <boost/spirit/fusion/iterator/next.hpp>
15#include <boost/spirit/fusion/iterator/equal_to.hpp>
16#include <boost/mpl/eval_if.hpp>
17#include <boost/mpl/identity.hpp>
18
19namespace boost { namespace fusion
20{
21    struct filter_view_iterator_tag;
22
23    template <typename First, typename Last, typename Pred>
24    struct filter_iterator;
25
26    namespace filter_view_detail {
27        template<typename Iterator>
28        struct next_traits_impl {
29            typedef typename Iterator::first_type first_type;
30            typedef typename Iterator::last_type last_type;
31            typedef typename Iterator::pred_type pred_type;
32
33            typedef typename
34                mpl::eval_if<
35                    meta::equal_to<first_type, last_type>
36                  , mpl::identity<last_type>
37                  , meta::next<first_type>
38                >::type
39            next_type;
40
41            typedef typename detail::static_find_if<
42                next_type, last_type, pred_type>
43            filter;
44
45            typedef filter_iterator<
46                typename filter::type, last_type, pred_type>
47            type;
48
49            static type
50            call(Iterator const& i);
51        };
52        template<typename Iterator>
53        typename next_traits_impl<Iterator>::type
54        next_traits_impl<Iterator>::call(Iterator const& i)
55        {
56            return type(filter::call(i.first));
57        }
58    }
59
60    namespace meta
61    {
62        template <typename Tag>
63        struct next_impl;
64
65        template <>
66        struct next_impl<filter_view_iterator_tag>
67        {
68            template <typename Iterator>
69            struct apply : filter_view_detail::next_traits_impl<Iterator>
70            {};
71        };
72    }
73}}
74
75#endif
76
77
Note: See TracBrowser for help on using the repository browser.