Chris@16
|
1
|
Chris@16
|
2 #ifndef BOOST_MPL_ITER_FOLD_IF_HPP_INCLUDED
|
Chris@16
|
3 #define BOOST_MPL_ITER_FOLD_IF_HPP_INCLUDED
|
Chris@16
|
4
|
Chris@16
|
5 // Copyright Aleksey Gurtovoy 2003-2004
|
Chris@16
|
6 // Copyright Eric Friedman 2003
|
Chris@16
|
7 //
|
Chris@16
|
8 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
9 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
10 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
11 //
|
Chris@16
|
12 // See http://www.boost.org/libs/mpl for documentation.
|
Chris@16
|
13
|
Chris@101
|
14 // $Id$
|
Chris@101
|
15 // $Date$
|
Chris@101
|
16 // $Revision$
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/mpl/begin_end.hpp>
|
Chris@16
|
19 #include <boost/mpl/logical.hpp>
|
Chris@16
|
20 #include <boost/mpl/always.hpp>
|
Chris@16
|
21 #include <boost/mpl/eval_if.hpp>
|
Chris@16
|
22 #include <boost/mpl/if.hpp>
|
Chris@16
|
23 #include <boost/mpl/pair.hpp>
|
Chris@16
|
24 #include <boost/mpl/apply.hpp>
|
Chris@16
|
25 #include <boost/mpl/aux_/iter_fold_if_impl.hpp>
|
Chris@16
|
26 #include <boost/mpl/aux_/na_spec.hpp>
|
Chris@16
|
27 #include <boost/mpl/aux_/lambda_support.hpp>
|
Chris@16
|
28 #include <boost/mpl/aux_/config/forwarding.hpp>
|
Chris@16
|
29 #include <boost/mpl/aux_/config/workaround.hpp>
|
Chris@16
|
30
|
Chris@16
|
31 #include <boost/type_traits/is_same.hpp>
|
Chris@16
|
32
|
Chris@16
|
33 namespace boost { namespace mpl {
|
Chris@16
|
34
|
Chris@16
|
35 namespace aux {
|
Chris@16
|
36
|
Chris@16
|
37 template< typename Predicate, typename LastIterator >
|
Chris@16
|
38 struct iter_fold_if_pred
|
Chris@16
|
39 {
|
Chris@16
|
40 template< typename State, typename Iterator > struct apply
|
Chris@16
|
41 #if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING)
|
Chris@16
|
42 : and_<
|
Chris@16
|
43 not_< is_same<Iterator,LastIterator> >
|
Chris@16
|
44 , apply1<Predicate,Iterator>
|
Chris@16
|
45 >
|
Chris@16
|
46 {
|
Chris@16
|
47 #else
|
Chris@16
|
48 {
|
Chris@16
|
49 typedef and_<
|
Chris@16
|
50 not_< is_same<Iterator,LastIterator> >
|
Chris@16
|
51 , apply1<Predicate,Iterator>
|
Chris@16
|
52 > type;
|
Chris@16
|
53 #endif
|
Chris@16
|
54 };
|
Chris@16
|
55 };
|
Chris@16
|
56
|
Chris@16
|
57 } // namespace aux
|
Chris@16
|
58
|
Chris@16
|
59 template<
|
Chris@16
|
60 typename BOOST_MPL_AUX_NA_PARAM(Sequence)
|
Chris@16
|
61 , typename BOOST_MPL_AUX_NA_PARAM(State)
|
Chris@16
|
62 , typename BOOST_MPL_AUX_NA_PARAM(ForwardOp)
|
Chris@16
|
63 , typename BOOST_MPL_AUX_NA_PARAM(ForwardPredicate)
|
Chris@16
|
64 , typename BOOST_MPL_AUX_NA_PARAM(BackwardOp)
|
Chris@16
|
65 , typename BOOST_MPL_AUX_NA_PARAM(BackwardPredicate)
|
Chris@16
|
66 >
|
Chris@16
|
67 struct iter_fold_if
|
Chris@16
|
68 {
|
Chris@16
|
69
|
Chris@16
|
70 typedef typename begin<Sequence>::type first_;
|
Chris@16
|
71 typedef typename end<Sequence>::type last_;
|
Chris@16
|
72
|
Chris@16
|
73 typedef typename eval_if<
|
Chris@16
|
74 is_na<BackwardPredicate>
|
Chris@16
|
75 , if_< is_na<BackwardOp>, always<false_>, always<true_> >
|
Chris@16
|
76 , identity<BackwardPredicate>
|
Chris@16
|
77 >::type backward_pred_;
|
Chris@16
|
78
|
Chris@16
|
79 // cwpro8 doesn't like 'cut-off' type here (use typedef instead)
|
Chris@16
|
80 #if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) && !BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600))
|
Chris@16
|
81 struct result_ :
|
Chris@16
|
82 #else
|
Chris@16
|
83 typedef
|
Chris@16
|
84 #endif
|
Chris@16
|
85 aux::iter_fold_if_impl<
|
Chris@16
|
86 first_
|
Chris@16
|
87 , State
|
Chris@16
|
88 , ForwardOp
|
Chris@16
|
89 , protect< aux::iter_fold_if_pred< ForwardPredicate,last_ > >
|
Chris@16
|
90 , BackwardOp
|
Chris@16
|
91 , backward_pred_
|
Chris@16
|
92 >
|
Chris@16
|
93 #if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) && !BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600))
|
Chris@16
|
94 { };
|
Chris@16
|
95 #else
|
Chris@16
|
96 result_;
|
Chris@16
|
97 #endif
|
Chris@16
|
98
|
Chris@16
|
99 public:
|
Chris@16
|
100
|
Chris@16
|
101 typedef pair<
|
Chris@16
|
102 typename result_::state
|
Chris@16
|
103 , typename result_::iterator
|
Chris@16
|
104 > type;
|
Chris@16
|
105
|
Chris@16
|
106 BOOST_MPL_AUX_LAMBDA_SUPPORT(
|
Chris@16
|
107 6
|
Chris@16
|
108 , iter_fold_if
|
Chris@16
|
109 , (Sequence,State,ForwardOp,ForwardPredicate,BackwardOp,BackwardPredicate)
|
Chris@16
|
110 )
|
Chris@16
|
111 };
|
Chris@16
|
112
|
Chris@16
|
113 BOOST_MPL_AUX_NA_SPEC(6, iter_fold_if)
|
Chris@16
|
114
|
Chris@16
|
115 }}
|
Chris@16
|
116
|
Chris@16
|
117 #endif // BOOST_MPL_ITER_FOLD_IF_HPP_INCLUDED
|