1 |
|
---|
2 | #ifndef BOOST_MPL_AUX_FILTER_ITER_HPP_INCLUDED
|
---|
3 | #define BOOST_MPL_AUX_FILTER_ITER_HPP_INCLUDED
|
---|
4 |
|
---|
5 | // Copyright Aleksey Gurtovoy 2000-2004
|
---|
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 | // $Source: /cvsroot/boost/boost/boost/mpl/aux_/filter_iter.hpp,v $
|
---|
14 | // $Date: 2004/09/07 12:07:56 $
|
---|
15 | // $Revision: 1.4 $
|
---|
16 |
|
---|
17 | #include <boost/mpl/find_if.hpp>
|
---|
18 | #include <boost/mpl/iterator_range.hpp>
|
---|
19 | #include <boost/mpl/iterator_tags.hpp>
|
---|
20 | #include <boost/mpl/deref.hpp>
|
---|
21 | #include <boost/mpl/aux_/lambda_spec.hpp>
|
---|
22 | #include <boost/mpl/aux_/config/ctps.hpp>
|
---|
23 | #include <boost/type_traits/is_same.hpp>
|
---|
24 |
|
---|
25 | namespace boost { namespace mpl {
|
---|
26 |
|
---|
27 | namespace aux {
|
---|
28 |
|
---|
29 | template<
|
---|
30 | typename Iterator
|
---|
31 | , typename LastIterator
|
---|
32 | , typename Predicate
|
---|
33 | >
|
---|
34 | struct filter_iter;
|
---|
35 |
|
---|
36 | template<
|
---|
37 | typename Iterator
|
---|
38 | , typename LastIterator
|
---|
39 | , typename Predicate
|
---|
40 | >
|
---|
41 | struct next_filter_iter
|
---|
42 | {
|
---|
43 | typedef typename find_if<
|
---|
44 | iterator_range<Iterator,LastIterator>
|
---|
45 | , Predicate
|
---|
46 | >::type base_iter_;
|
---|
47 |
|
---|
48 | typedef filter_iter<base_iter_,LastIterator,Predicate> type;
|
---|
49 | };
|
---|
50 |
|
---|
51 | #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
---|
52 |
|
---|
53 | template<
|
---|
54 | typename Iterator
|
---|
55 | , typename LastIterator
|
---|
56 | , typename Predicate
|
---|
57 | >
|
---|
58 | struct filter_iter
|
---|
59 | {
|
---|
60 | typedef Iterator base;
|
---|
61 | typedef forward_iterator_tag category;
|
---|
62 | typedef typename aux::next_filter_iter<
|
---|
63 | typename mpl::next<base>::type
|
---|
64 | , LastIterator
|
---|
65 | , Predicate
|
---|
66 | >::type next;
|
---|
67 |
|
---|
68 | typedef typename deref<base>::type type;
|
---|
69 | };
|
---|
70 |
|
---|
71 | template<
|
---|
72 | typename LastIterator
|
---|
73 | , typename Predicate
|
---|
74 | >
|
---|
75 | struct filter_iter< LastIterator,LastIterator,Predicate >
|
---|
76 | {
|
---|
77 | typedef LastIterator base;
|
---|
78 | typedef forward_iterator_tag category;
|
---|
79 | };
|
---|
80 |
|
---|
81 | #else
|
---|
82 |
|
---|
83 | template< bool >
|
---|
84 | struct filter_iter_impl
|
---|
85 | {
|
---|
86 | template<
|
---|
87 | typename Iterator
|
---|
88 | , typename LastIterator
|
---|
89 | , typename Predicate
|
---|
90 | >
|
---|
91 | struct result_
|
---|
92 | {
|
---|
93 | typedef Iterator base;
|
---|
94 | typedef forward_iterator_tag category;
|
---|
95 | typedef typename next_filter_iter<
|
---|
96 | typename mpl::next<Iterator>::type
|
---|
97 | , LastIterator
|
---|
98 | , Predicate
|
---|
99 | >::type next;
|
---|
100 |
|
---|
101 | typedef typename deref<base>::type type;
|
---|
102 | };
|
---|
103 | };
|
---|
104 |
|
---|
105 | template<>
|
---|
106 | struct filter_iter_impl< true >
|
---|
107 | {
|
---|
108 | template<
|
---|
109 | typename Iterator
|
---|
110 | , typename LastIterator
|
---|
111 | , typename Predicate
|
---|
112 | >
|
---|
113 | struct result_
|
---|
114 | {
|
---|
115 | typedef Iterator base;
|
---|
116 | typedef forward_iterator_tag category;
|
---|
117 | };
|
---|
118 | };
|
---|
119 |
|
---|
120 | template<
|
---|
121 | typename Iterator
|
---|
122 | , typename LastIterator
|
---|
123 | , typename Predicate
|
---|
124 | >
|
---|
125 | struct filter_iter
|
---|
126 | : filter_iter_impl<
|
---|
127 | ::boost::is_same<Iterator,LastIterator>::value
|
---|
128 | >::template result_< Iterator,LastIterator,Predicate >
|
---|
129 | {
|
---|
130 | };
|
---|
131 |
|
---|
132 | #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
---|
133 |
|
---|
134 | } // namespace aux
|
---|
135 |
|
---|
136 | BOOST_MPL_AUX_PASS_THROUGH_LAMBDA_SPEC(3, aux::filter_iter)
|
---|
137 |
|
---|
138 | }}
|
---|
139 |
|
---|
140 | #endif // BOOST_MPL_AUX_FILTER_ITER_HPP_INCLUDED
|
---|