Files
boost_mpl/include/boost/mpl/iter_fold_if.hpp
T

117 lines
3.0 KiB
C++
Raw Normal View History

2003-11-07 04:30:08 +00:00
#ifndef BOOST_MPL_ITER_FOLD_IF_HPP_INCLUDED
#define BOOST_MPL_ITER_FOLD_IF_HPP_INCLUDED
2004-09-02 15:41:37 +00:00
// Copyright Aleksey Gurtovoy 2003-2004
// Copyright Eric Friedman 2003
//
// 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.
2003-11-07 04:30:08 +00:00
2004-09-02 15:41:37 +00:00
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/logical.hpp>
#include <boost/mpl/always.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/pair.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/aux_/iter_fold_if_impl.hpp>
#include <boost/mpl/aux_/na_spec.hpp>
#include <boost/mpl/aux_/lambda_support.hpp>
#include <boost/mpl/aux_/config/forwarding.hpp>
#include <boost/mpl/aux_/config/workaround.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost { namespace mpl {
2003-11-07 04:30:08 +00:00
2003-11-08 11:53:00 +00:00
namespace aux {
template< typename Predicate, typename LastIterator >
struct iter_fold_if_pred
{
2004-09-02 15:41:37 +00:00
template< typename State, typename Iterator > struct apply
#if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING)
: and_<
not_< is_same<Iterator,LastIterator> >
, apply1<Predicate,Iterator>
>
{
#else
2003-11-08 11:53:00 +00:00
{
typedef and_<
not_< is_same<Iterator,LastIterator> >
, apply1<Predicate,Iterator>
> type;
2004-09-02 15:41:37 +00:00
#endif
2003-11-08 11:53:00 +00:00
};
};
} // namespace aux
2003-11-07 04:30:08 +00:00
template<
2004-09-02 15:41:37 +00:00
typename BOOST_MPL_AUX_NA_PARAM(Sequence)
, typename BOOST_MPL_AUX_NA_PARAM(State)
, 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)
2003-11-07 04:30:08 +00:00
>
struct iter_fold_if
{
2003-11-08 11:53:00 +00:00
typedef typename begin<Sequence>::type first_;
typedef typename end<Sequence>::type last_;
2004-09-02 15:41:37 +00:00
typedef typename eval_if<
is_na<BackwardPredicate>
, if_< is_na<BackwardOp>, always<false_>, always<true_> >
, identity<BackwardPredicate>
2003-11-08 11:53:00 +00:00
>::type backward_pred_;
2003-11-07 04:30:08 +00:00
// 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))
2003-11-07 04:30:08 +00:00
struct result_ :
#else
typedef
#endif
aux::iter_fold_if_impl<
2003-11-08 11:53:00 +00:00
first_
2003-11-07 04:30:08 +00:00
, State
2004-09-02 15:41:37 +00:00
, ForwardOp
, protect< aux::iter_fold_if_pred< ForwardPredicate,last_ > >
, BackwardOp
2003-11-08 11:53:00 +00:00
, backward_pred_
2003-11-07 04:30:08 +00:00
>
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) && !BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600))
2003-11-07 04:30:08 +00:00
{ };
#else
result_;
#endif
public:
typedef pair<
typename result_::state
, typename result_::iterator
> type;
BOOST_MPL_AUX_LAMBDA_SUPPORT(
6
, iter_fold_if
2003-11-08 11:53:00 +00:00
, (Sequence,State,ForwardOp,ForwardPredicate,BackwardOp,BackwardPredicate)
2003-11-07 04:30:08 +00:00
)
};
2004-09-02 15:41:37 +00:00
BOOST_MPL_AUX_NA_SPEC(6, iter_fold_if)
2003-11-07 04:30:08 +00:00
2004-09-02 15:41:37 +00:00
}}
2003-11-07 04:30:08 +00:00
#endif // BOOST_MPL_ITER_FOLD_IF_HPP_INCLUDED