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