Added public interface to iter_fold_if.

[SVN r20716]
This commit is contained in:
Eric Friedman
2003-11-07 04:30:08 +00:00
parent b8440aeef8
commit d1a2e748f8
2 changed files with 95 additions and 24 deletions

View File

@@ -19,14 +19,13 @@
#include "boost/mpl/aux_/config/workaround.hpp" #include "boost/mpl/aux_/config/workaround.hpp"
#include "boost/mpl/aux_/find_if_pred.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/begin_end.hpp"
#include "boost/mpl/bool.hpp"
#include "boost/mpl/if.hpp" #include "boost/mpl/if.hpp"
#include "boost/mpl/int.hpp" #include "boost/mpl/int.hpp"
#include "boost/mpl/iter_fold_if.hpp"
#include "boost/mpl/lambda.hpp" #include "boost/mpl/lambda.hpp"
#include "boost/mpl/next.hpp" #include "boost/mpl/next.hpp"
#include "boost/mpl/protect.hpp"
#include "boost/mpl/void.hpp" #include "boost/mpl/void.hpp"
#include "boost/mpl/aux_/void_spec.hpp" #include "boost/mpl/aux_/void_spec.hpp"
#include "boost/mpl/aux_/lambda_support.hpp" #include "boost/mpl/aux_/lambda_support.hpp"
@@ -56,35 +55,24 @@ template<
> >
struct index_if struct index_if
{ {
private: private:
typedef typename begin<Sequence>::type first_; typedef typename begin<Sequence>::type first_;
typedef typename end<Sequence>::type last_; typedef typename end<Sequence>::type last_;
typedef typename lambda<Predicate>::type pred_; typedef typename lambda<Predicate>::type pred_;
// cwpro8 doesn't like 'cut-off' type here (use typedef instead) typedef typename iter_fold_if<
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
struct result_ :
#else
typedef
#endif
aux::iter_fold_if_impl<
first_ first_
, int_<0> , int_<0>
, aux::index_if_op , protect< aux::index_if_op >
, aux::find_if_pred<pred_,last_> , protect< aux::find_if_pred<pred_,last_> >
, void >::type result_;
, always<false_>
>
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
{ };
#else
result_;
#endif
typedef typename result_::state result_index_; typedef typename result_::first result_index_;
typedef typename result_::iterator result_iterator_; typedef typename result_::second result_iterator_;
public:
public:
typedef typename if_< typedef typename if_<
is_same< result_iterator_,last_ > is_same< result_iterator_,last_ >
, void_ , void_

View File

@@ -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<false_>
>
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<ForwardOp>::type
, typename lambda<ForwardPredicate>::type
, typename lambda<BackwardOp>::type
, typename lambda<BackwardPredicate>::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