Index: boost/mpl/equal.hpp =================================================================== --- boost/mpl/equal.hpp (revision 53096) +++ boost/mpl/equal.hpp (working copy) @@ -74,8 +74,7 @@ , first2_ , next<> , protect< aux::equal_pred > - , void_ - , always + , identity<> > fold_; typedef typename fold_::iterator iter1_; Index: boost/mpl/aux_/iter_fold_if_impl.hpp =================================================================== --- boost/mpl/aux_/iter_fold_if_impl.hpp (revision 53096) +++ boost/mpl/aux_/iter_fold_if_impl.hpp (working copy) @@ -81,6 +81,34 @@ }; }; +template< bool > +struct iter_fold_if_backward_step_impl +{ + template< + typename Iterator + , typename State + , typename StateOp + > + struct result_ + { + typedef typename apply2::type state; + }; +}; + +template<> +struct iter_fold_if_backward_step_impl +{ + template< + typename Iterator + , typename State + , typename StateOp + > + struct result_ + { + typedef State state; + }; +}; + // agurt, 25/jun/02: MSVC 6.5 workaround, had to get rid of inheritance // here and in 'iter_fold_if_backward_step', because sometimes it interfered // with the "early template instantiation bug" in _really_ ugly ways @@ -104,18 +132,16 @@ template< typename Iterator , typename State + , typename ForwardNotLast , typename BackwardOp - , typename Predicate > struct iter_fold_if_backward_step { - typedef typename apply2::type not_last; - typedef typename iter_fold_if_step_impl< - BOOST_MPL_AUX_MSVC_VALUE_WKND(not_last)::value - >::template result_< Iterator,State,BackwardOp,identity > impl_; + typedef typename iter_fold_if_backward_step_impl< + BOOST_MPL_AUX_MSVC_VALUE_WKND(ForwardNotLast)::value + >::template result_< Iterator,State,BackwardOp> impl_; typedef typename impl_::state state; - typedef typename impl_::iterator iterator; }; @@ -134,8 +160,8 @@ typedef iter_fold_if_backward_step< \ typename BOOST_PP_CAT(forward_step,BOOST_PP_DEC(i))::iterator \ , typename BOOST_PP_CAT(backward_step,i)::state \ + , typename BOOST_PP_CAT(forward_step,i)::not_last \ , BackwardOp \ - , BackwardPredicate \ > BOOST_PP_CAT(backward_step,BOOST_PP_DEC(i)); \ /**/ @@ -159,7 +185,6 @@ , typename ForwardOp , typename ForwardPredicate , typename BackwardOp - , typename BackwardPredicate > struct iter_fold_if_impl { @@ -179,7 +204,6 @@ , ForwardOp , ForwardPredicate , BackwardOp - , BackwardPredicate > , iter_fold_if_null_step< typename AUX_LAST_FORWARD_STEP::iterator Index: boost/mpl/iter_fold_if.hpp =================================================================== --- boost/mpl/iter_fold_if.hpp (revision 53096) +++ boost/mpl/iter_fold_if.hpp (working copy) @@ -62,7 +62,6 @@ , typename BOOST_MPL_AUX_NA_PARAM(ForwardOp) , typename BOOST_MPL_AUX_NA_PARAM(ForwardPredicate) , typename BOOST_MPL_AUX_NA_PARAM(BackwardOp) - , typename BOOST_MPL_AUX_NA_PARAM(BackwardPredicate) > struct iter_fold_if { @@ -70,11 +69,7 @@ typedef typename begin::type first_; typedef typename end::type last_; - typedef typename eval_if< - is_na - , if_< is_na, always, always > - , identity - >::type backward_pred_; + typedef typename if_< is_na, identity<>, BackwardOp >::type backward_op_; // cwpro8 doesn't like 'cut-off' type here (use typedef instead) #if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) && !BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) @@ -87,8 +82,7 @@ , State , ForwardOp , protect< aux::iter_fold_if_pred< ForwardPredicate,last_ > > - , BackwardOp - , backward_pred_ + , backward_op_ > #if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) && !BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) { }; @@ -104,13 +98,13 @@ > type; BOOST_MPL_AUX_LAMBDA_SUPPORT( - 6 + 5 , iter_fold_if - , (Sequence,State,ForwardOp,ForwardPredicate,BackwardOp,BackwardPredicate) + , (Sequence,State,ForwardOp,ForwardPredicate,BackwardOp) ) }; -BOOST_MPL_AUX_NA_SPEC(6, iter_fold_if) +BOOST_MPL_AUX_NA_SPEC(5, iter_fold_if) }} Index: libs/mpl/test/iter_fold_if.cpp =================================================================== --- libs/mpl/test/iter_fold_if.cpp (revision 0) +++ libs/mpl/test/iter_fold_if.cpp (revision 0) @@ -0,0 +1,72 @@ + +// Copyright Steven Watanabe 2009 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date: $ +// $Revision: $ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +MPL_TEST_CASE() +{ + typedef iter_fold_if, void, deref<_2>, always, deref<_2> >::type result; + MPL_ASSERT((is_same)); +} + +MPL_TEST_CASE() // test forward fold functionality +{ + typedef list types; + typedef iter_fold_if, always >::type result; + MPL_ASSERT((is_same)); + MPL_ASSERT((is_same::type>)); +} + +MPL_TEST_CASE() // test reverse fold functionality +{ + typedef list types; + typedef iter_fold_if, always, deref<_2> >::type result; + MPL_ASSERT((is_same)); + MPL_ASSERT((is_same::type>)); +} + +MPL_TEST_CASE() // test forward condition +{ + typedef list_c numbers; + typedef iter_fold_if, plus<_1, deref<_2> >, not_equal_to, int_<8> > >::type result; + MPL_ASSERT((equal_to >)); + MPL_ASSERT((is_same::type, 3>::type>)); +} + + +MPL_TEST_CASE() // test backwards condition +{ + typedef list_c numbers; + typedef iter_fold_if< + numbers + , int_<0> + , identity<_1> + , not_equal_to, int_<8> > + , plus<_1, deref<_2> > + >::type result; + MPL_ASSERT((equal_to >)); + MPL_ASSERT((is_same::type, 3>::type>)); +} Property changes on: libs\mpl\test\iter_fold_if.cpp ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Index: libs/mpl/test/Jamfile.v2 =================================================================== --- libs/mpl/test/Jamfile.v2 (revision 53096) +++ libs/mpl/test/Jamfile.v2 (working copy) @@ -49,6 +49,7 @@ compile is_placeholder.cpp ; compile is_sequence.cpp ; compile iterator_tags.cpp ; +compile iter_fold_if.cpp ; compile joint_view.cpp ; compile lambda.cpp ; compile lambda_args.cpp ;