mirror of
https://github.com/boostorg/mpl.git
synced 2025-08-03 14:54:30 +02:00
Modified public iter_fold_if behavior.
[SVN r20755]
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2000-02
|
||||
// Aleksey Gurtovoy
|
||||
// Aleksey Gurtovoy, Eric Friedman
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
@@ -18,25 +18,19 @@
|
||||
#define BOOST_MPL_AUX_FIND_IF_PRED_HPP_INCLUDED
|
||||
|
||||
#include "boost/mpl/aux_/iter_apply.hpp"
|
||||
#include "boost/mpl/apply.hpp"
|
||||
#include "boost/mpl/not.hpp"
|
||||
#include "boost/mpl/or.hpp"
|
||||
#include "boost/type_traits/is_same.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace mpl {
|
||||
namespace aux {
|
||||
|
||||
template< typename Predicate, typename LastIterator >
|
||||
template< typename Predicate >
|
||||
struct find_if_pred
|
||||
{
|
||||
template< typename State, typename Iterator >
|
||||
template< typename Iterator >
|
||||
struct apply
|
||||
{
|
||||
typedef not_< or_<
|
||||
is_same<Iterator,LastIterator>
|
||||
, aux::iter_apply1<Predicate,Iterator>
|
||||
> > type;
|
||||
typedef not_< aux::iter_apply1<Predicate,Iterator> > type;
|
||||
};
|
||||
};
|
||||
|
||||
|
@@ -18,36 +18,16 @@
|
||||
#define BOOST_MPL_FIND_IF_HPP_INCLUDED
|
||||
|
||||
#include "boost/mpl/aux_/find_if_pred.hpp"
|
||||
#include "boost/mpl/aux_/iter_fold_if_impl.hpp"
|
||||
#include "boost/mpl/begin_end.hpp"
|
||||
#include "boost/mpl/always.hpp"
|
||||
#include "boost/mpl/arg.hpp"
|
||||
#include "boost/mpl/lambda.hpp"
|
||||
#include "boost/mpl/iter_fold_if.hpp"
|
||||
#include "boost/mpl/protect.hpp"
|
||||
#include "boost/mpl/aux_/void_spec.hpp"
|
||||
#include "boost/mpl/aux_/lambda_support.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace mpl {
|
||||
|
||||
namespace aux {
|
||||
/*
|
||||
template< typename LastIterator >
|
||||
struct find_if_pred
|
||||
{
|
||||
template<
|
||||
typename Predicate
|
||||
, typename Iterator
|
||||
>
|
||||
struct apply
|
||||
{
|
||||
typedef typename not_< or_<
|
||||
is_same<Iterator,LastIterator>
|
||||
, aux::iter_apply1<Predicate,Iterator>
|
||||
> >::type type;
|
||||
};
|
||||
};
|
||||
*/
|
||||
} // namespace aux
|
||||
|
||||
BOOST_MPL_AUX_AGLORITHM_NAMESPACE_BEGIN
|
||||
|
||||
template<
|
||||
@@ -56,22 +36,23 @@ template<
|
||||
>
|
||||
struct find_if
|
||||
{
|
||||
private:
|
||||
typedef typename begin<Sequence>::type first_;
|
||||
typedef typename end<Sequence>::type last_;
|
||||
private:
|
||||
|
||||
typedef typename lambda<Predicate>::type pred_;
|
||||
|
||||
public:
|
||||
typedef typename aux::iter_fold_if_impl<
|
||||
first_
|
||||
typedef typename iter_fold_if<
|
||||
Sequence
|
||||
, void
|
||||
, mpl::arg<1>
|
||||
, aux::find_if_pred< pred_, last_ >
|
||||
, void
|
||||
, always<false_>
|
||||
>::iterator type;
|
||||
, protect< arg<1> > // ignore
|
||||
, protect< aux::find_if_pred<pred_> >
|
||||
>::type result_;
|
||||
|
||||
public:
|
||||
|
||||
typedef typename result_::second type;
|
||||
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(2,find_if,(Sequence,Predicate))
|
||||
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_AGLORITHM_NAMESPACE_END
|
||||
|
@@ -57,29 +57,29 @@ struct index_if
|
||||
{
|
||||
private:
|
||||
|
||||
typedef typename begin<Sequence>::type first_;
|
||||
typedef typename end<Sequence>::type last_;
|
||||
typedef typename lambda<Predicate>::type pred_;
|
||||
|
||||
typedef typename iter_fold_if<
|
||||
first_
|
||||
Sequence
|
||||
, int_<0>
|
||||
, protect< aux::index_if_op >
|
||||
, protect< aux::find_if_pred<pred_,last_> >
|
||||
, protect< aux::find_if_pred<pred_> >
|
||||
>::type result_;
|
||||
|
||||
typedef typename end<Sequence>::type not_found_;
|
||||
typedef typename result_::first result_index_;
|
||||
typedef typename result_::second result_iterator_;
|
||||
|
||||
public:
|
||||
|
||||
typedef typename if_<
|
||||
is_same< result_iterator_,last_ >
|
||||
is_same< result_iterator_,not_found_ >
|
||||
, void_
|
||||
, result_index_
|
||||
>::type type;
|
||||
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(2,index_if,(Sequence,Predicate))
|
||||
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_AGLORITHM_NAMESPACE_END
|
||||
|
@@ -4,7 +4,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003
|
||||
// Eric Friedman
|
||||
// Eric Friedman, Aleksey Gurtovoy
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
@@ -18,29 +18,65 @@
|
||||
#define BOOST_MPL_ITER_FOLD_IF_HPP_INCLUDED
|
||||
|
||||
#include "boost/mpl/aux_/iter_fold_if_impl.hpp"
|
||||
#include "boost/mpl/and.hpp"
|
||||
#include "boost/mpl/always.hpp"
|
||||
#include "boost/mpl/apply.hpp"
|
||||
#include "boost/mpl/apply_if.hpp"
|
||||
#include "boost/mpl/begin_end.hpp"
|
||||
#include "boost/mpl/bool.hpp"
|
||||
#include "boost/mpl/if.hpp"
|
||||
#include "boost/mpl/lambda.hpp"
|
||||
#include "boost/mpl/not.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"
|
||||
#include "boost/type_traits/is_same.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace mpl {
|
||||
|
||||
namespace aux {
|
||||
|
||||
template< typename Predicate, typename LastIterator >
|
||||
struct iter_fold_if_pred
|
||||
{
|
||||
template< typename State, typename Iterator >
|
||||
struct apply
|
||||
{
|
||||
typedef and_<
|
||||
not_< is_same<Iterator,LastIterator> >
|
||||
, apply1<Predicate,Iterator>
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace aux
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_VOID_SPEC_PARAM(Iterator)
|
||||
typename BOOST_MPL_AUX_VOID_SPEC_PARAM(Sequence)
|
||||
, 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_>
|
||||
, typename BackwardPredicate = void_
|
||||
>
|
||||
struct iter_fold_if
|
||||
{
|
||||
private:
|
||||
|
||||
typedef typename begin<Sequence>::type first_;
|
||||
typedef typename end<Sequence>::type last_;
|
||||
typedef typename lambda<ForwardOp>::type forward_op_;
|
||||
typedef typename lambda<ForwardPredicate>::type forward_pred_;
|
||||
typedef typename lambda<BackwardOp>::type backward_op_;
|
||||
|
||||
typedef typename apply_if<
|
||||
is_void_<BackwardPredicate>
|
||||
, if_< is_void_<BackwardOp>, always<false_>, always<true_> >
|
||||
, lambda<BackwardPredicate>
|
||||
>::type backward_pred_;
|
||||
|
||||
// cwpro8 doesn't like 'cut-off' type here (use typedef instead)
|
||||
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
|
||||
struct result_ :
|
||||
@@ -48,12 +84,12 @@ private:
|
||||
typedef
|
||||
#endif
|
||||
aux::iter_fold_if_impl<
|
||||
Iterator
|
||||
first_
|
||||
, State
|
||||
, typename lambda<ForwardOp>::type
|
||||
, typename lambda<ForwardPredicate>::type
|
||||
, typename lambda<BackwardOp>::type
|
||||
, typename lambda<BackwardPredicate>::type
|
||||
, forward_op_
|
||||
, aux::iter_fold_if_pred< forward_pred_,last_ >
|
||||
, backward_op_
|
||||
, backward_pred_
|
||||
>
|
||||
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
|
||||
{ };
|
||||
@@ -71,7 +107,7 @@ public:
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(
|
||||
6
|
||||
, iter_fold_if
|
||||
, (Iterator,State,ForwardOp,ForwardPredicate,BackwardOp,BackwardPredicate)
|
||||
, (Sequence,State,ForwardOp,ForwardPredicate,BackwardOp,BackwardPredicate)
|
||||
)
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user