From d1a2e748f887fb231f698f4b3a35d6aff0cf259e Mon Sep 17 00:00:00 2001 From: Eric Friedman Date: Fri, 7 Nov 2003 04:30:08 +0000 Subject: [PATCH] Added public interface to iter_fold_if. [SVN r20716] --- include/boost/mpl/index_if.hpp | 36 +++++-------- include/boost/mpl/iter_fold_if.hpp | 83 ++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 24 deletions(-) create mode 100644 include/boost/mpl/iter_fold_if.hpp diff --git a/include/boost/mpl/index_if.hpp b/include/boost/mpl/index_if.hpp index 9b4ad5d..2740788 100644 --- a/include/boost/mpl/index_if.hpp +++ b/include/boost/mpl/index_if.hpp @@ -19,14 +19,13 @@ #include "boost/mpl/aux_/config/workaround.hpp" #include "boost/mpl/aux_/find_if_pred.hpp" -#include "boost/mpl/aux_/iter_fold_if_impl.hpp" -#include "boost/mpl/always.hpp" #include "boost/mpl/begin_end.hpp" -#include "boost/mpl/bool.hpp" #include "boost/mpl/if.hpp" #include "boost/mpl/int.hpp" +#include "boost/mpl/iter_fold_if.hpp" #include "boost/mpl/lambda.hpp" #include "boost/mpl/next.hpp" +#include "boost/mpl/protect.hpp" #include "boost/mpl/void.hpp" #include "boost/mpl/aux_/void_spec.hpp" #include "boost/mpl/aux_/lambda_support.hpp" @@ -56,35 +55,24 @@ template< > struct index_if { - private: +private: + typedef typename begin::type first_; typedef typename end::type last_; typedef typename lambda::type pred_; -// cwpro8 doesn't like 'cut-off' type here (use typedef instead) -#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) - struct result_ : -#else - typedef -#endif - aux::iter_fold_if_impl< + typedef typename iter_fold_if< first_ , int_<0> - , aux::index_if_op - , aux::find_if_pred - , void - , always - > -#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) - { }; -#else - result_; -#endif + , protect< aux::index_if_op > + , protect< aux::find_if_pred > + >::type result_; - typedef typename result_::state result_index_; - typedef typename result_::iterator result_iterator_; + typedef typename result_::first result_index_; + typedef typename result_::second result_iterator_; + +public: - public: typedef typename if_< is_same< result_iterator_,last_ > , void_ diff --git a/include/boost/mpl/iter_fold_if.hpp b/include/boost/mpl/iter_fold_if.hpp new file mode 100644 index 0000000..3c2a332 --- /dev/null +++ b/include/boost/mpl/iter_fold_if.hpp @@ -0,0 +1,83 @@ +//----------------------------------------------------------------------------- +// boost mpl/iter_fold_if.hpp header file +// See http://www.boost.org for updates, documentation, and revision history. +//----------------------------------------------------------------------------- +// +// Copyright (c) 2003 +// Eric Friedman +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appears in all copies and +// that both the copyright notice and this permission notice appear in +// supporting documentation. No representations are made about the +// suitability of this software for any purpose. It is provided "as is" +// without express or implied warranty. + +#ifndef BOOST_MPL_ITER_FOLD_IF_HPP_INCLUDED +#define BOOST_MPL_ITER_FOLD_IF_HPP_INCLUDED + +#include "boost/mpl/aux_/iter_fold_if_impl.hpp" +#include "boost/mpl/always.hpp" +#include "boost/mpl/bool.hpp" +#include "boost/mpl/lambda.hpp" +#include "boost/mpl/pair.hpp" +#include "boost/mpl/void.hpp" +#include "boost/mpl/aux_/void_spec.hpp" +#include "boost/mpl/aux_/lambda_support.hpp" + +namespace boost { +namespace mpl { + +template< + typename BOOST_MPL_AUX_VOID_SPEC_PARAM(Iterator) + , typename BOOST_MPL_AUX_VOID_SPEC_PARAM(State) + , typename BOOST_MPL_AUX_VOID_SPEC_PARAM(ForwardOp) + , typename BOOST_MPL_AUX_VOID_SPEC_PARAM(ForwardPredicate) + , typename BackwardOp = void_ + , typename BackwardPredicate = always + > +struct iter_fold_if +{ +private: + +// cwpro8 doesn't like 'cut-off' type here (use typedef instead) +#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) + struct result_ : +#else + typedef +#endif + aux::iter_fold_if_impl< + Iterator + , State + , typename lambda::type + , typename lambda::type + , typename lambda::type + , typename lambda::type + > +#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) + { }; +#else + result_; +#endif + +public: + + typedef pair< + typename result_::state + , typename result_::iterator + > type; + + BOOST_MPL_AUX_LAMBDA_SUPPORT( + 6 + , iter_fold_if + , (Iterator,State,ForwardOp,ForwardPredicate,BackwardOp,BackwardPredicate) + ) +}; + +BOOST_MPL_AUX_VOID_SPEC(4, iter_fold_if) + +} // namespace mpl +} // namespace boost + +#endif // BOOST_MPL_ITER_FOLD_IF_HPP_INCLUDED