2 #ifndef BOOST_MPL_ITER_FOLD_IF_HPP_INCLUDED
3 #define BOOST_MPL_ITER_FOLD_IF_HPP_INCLUDED
5 // Copyright Aleksey Gurtovoy 2003-2004
6 // Copyright Eric Friedman 2003
8 // Distributed under the Boost Software License, Version 1.0.
9 // (See accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt)
12 // See http://www.boost.org/libs/mpl for documentation.
15 // $Date: 2004-09-02 11:41:37 -0400 (Thu, 02 Sep 2004) $
18 #include <boost/mpl/begin_end.hpp>
19 #include <boost/mpl/logical.hpp>
20 #include <boost/mpl/always.hpp>
21 #include <boost/mpl/eval_if.hpp>
22 #include <boost/mpl/if.hpp>
23 #include <boost/mpl/pair.hpp>
24 #include <boost/mpl/apply.hpp>
25 #include <boost/mpl/aux_/iter_fold_if_impl.hpp>
26 #include <boost/mpl/aux_/na_spec.hpp>
27 #include <boost/mpl/aux_/lambda_support.hpp>
28 #include <boost/mpl/aux_/config/forwarding.hpp>
29 #include <boost/mpl/aux_/config/workaround.hpp>
31 #include <boost/type_traits/is_same.hpp>
33 namespace boost { namespace mpl {
37 template< typename Predicate, typename LastIterator >
38 struct iter_fold_if_pred
40 template< typename State, typename Iterator > struct apply
41 #if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING)
43 not_< is_same<Iterator,LastIterator> >
44 , apply1<Predicate,Iterator>
50 not_< is_same<Iterator,LastIterator> >
51 , apply1<Predicate,Iterator>
60 typename BOOST_MPL_AUX_NA_PARAM(Sequence)
61 , typename BOOST_MPL_AUX_NA_PARAM(State)
62 , typename BOOST_MPL_AUX_NA_PARAM(ForwardOp)
63 , typename BOOST_MPL_AUX_NA_PARAM(ForwardPredicate)
64 , typename BOOST_MPL_AUX_NA_PARAM(BackwardOp)
65 , typename BOOST_MPL_AUX_NA_PARAM(BackwardPredicate)
70 typedef typename begin<Sequence>::type first_;
71 typedef typename end<Sequence>::type last_;
73 typedef typename eval_if<
74 is_na<BackwardPredicate>
75 , if_< is_na<BackwardOp>, always<false_>, always<true_> >
76 , identity<BackwardPredicate>
77 >::type backward_pred_;
79 // cwpro8 doesn't like 'cut-off' type here (use typedef instead)
80 #if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) && !BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600))
85 aux::iter_fold_if_impl<
89 , protect< aux::iter_fold_if_pred< ForwardPredicate,last_ > >
93 #if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) && !BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600))
102 typename result_::state
103 , typename result_::iterator
106 BOOST_MPL_AUX_LAMBDA_SUPPORT(
109 , (Sequence,State,ForwardOp,ForwardPredicate,BackwardOp,BackwardPredicate)
113 BOOST_MPL_AUX_NA_SPEC(6, iter_fold_if)
117 #endif // BOOST_MPL_ITER_FOLD_IF_HPP_INCLUDED