make find and find_if algorithms segment-aware, stylistic consistency tweaks

[SVN r73892]
This commit is contained in:
Eric Niebler
2011-08-18 17:12:05 +00:00
parent 528ad04fdb
commit 9dd14c435e
27 changed files with 623 additions and 539 deletions

View File

@ -12,18 +12,18 @@
namespace boost { namespace fusion { namespace detail namespace boost { namespace fusion { namespace detail
{ {
template<typename Fun> template <typename Fun>
struct segmented_fold_fun struct segmented_fold_fun
{ {
template<typename Sig> template <typename Sig>
struct result; struct result;
template<typename This, typename Range, typename State, typename Context> template <typename This, typename Sequence, typename State, typename Context>
struct result<This(Range&, State&, Context&)> struct result<This(Sequence&, State&, Context&)>
{ {
typedef typedef
fusion::result< fusion::result<
typename result_of::fold<Range, State, Fun>::type, typename result_of::fold<Sequence, State, Fun>::type,
continue_ continue_
> >
type; type;
@ -33,11 +33,11 @@ namespace boost { namespace fusion { namespace detail
: fun(f) : fun(f)
{} {}
template<typename Range, typename State, typename Context> template <typename Sequence, typename State, typename Context>
typename result<segmented_fold_fun(Range&, State const&, Context const&)>::type typename result<segmented_fold_fun(Sequence&, State const&, Context const&)>::type
operator()(Range& rng, State const& state, Context const&) const operator()(Sequence& seq, State const& state, Context const&) const
{ {
return fusion::fold(rng, state, fun); return fusion::fold(seq, state, fun);
} }
Fun const& fun; Fun const& fun;

View File

@ -13,7 +13,7 @@
namespace boost { namespace fusion { namespace detail namespace boost { namespace fusion { namespace detail
{ {
template<typename Fun> template <typename Fun>
struct segmented_for_each_fun struct segmented_for_each_fun
{ {
typedef result<void, continue_> result_type; typedef result<void, continue_> result_type;
@ -22,10 +22,10 @@ namespace boost { namespace fusion { namespace detail
: fun(f) : fun(f)
{} {}
template<typename Range, typename State, typename Context> template <typename Sequence, typename State, typename Context>
result_type operator()(Range& rng, State const&, Context const&) const result_type operator()(Sequence& seq, State const&, Context const&) const
{ {
fusion::for_each(rng, fun); fusion::for_each(seq, fun);
return void_(); return void_();
} }

View File

@ -9,19 +9,18 @@
#if !defined(FUSION_FIND_IF_05052005_1107) #if !defined(FUSION_FIND_IF_05052005_1107)
#define FUSION_FIND_IF_05052005_1107 #define FUSION_FIND_IF_05052005_1107
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/or.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/apply.hpp> #include <boost/mpl/apply.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp> #include <boost/mpl/identity.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/or.hpp>
#include <boost/fusion/iterator/advance.hpp>
#include <boost/fusion/iterator/distance.hpp>
#include <boost/fusion/iterator/equal_to.hpp> #include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/iterator/next.hpp> #include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp> #include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/iterator/advance.hpp> #include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/iterator/distance.hpp>
#include <boost/fusion/support/category_of.hpp> #include <boost/fusion/support/category_of.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
namespace boost { namespace fusion { namespace boost { namespace fusion {
struct random_access_traversal_tag; struct random_access_traversal_tag;
@ -222,10 +221,31 @@ namespace detail
template <typename Iterator> template <typename Iterator>
static type static type
call(Iterator const& iter) iter_call(Iterator const& iter)
{ {
return choose_call(iter, typename traits::category_of<Iterator>::type()); return choose_call(iter, typename traits::category_of<Iterator>::type());
} }
template <typename Sequence>
static type
call(Sequence& seq)
{
return iter_call(fusion::begin(seq));
}
};
template <typename Sequence, typename Pred>
struct result_of_find_if
{
typedef
static_find_if<
typename result_of::begin<Sequence>::type
, typename result_of::end<Sequence>::type
, Pred
>
filter;
typedef typename filter::type type;
}; };
}}} }}}

View File

@ -0,0 +1,106 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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)
==============================================================================*/
#if !defined(BOOST_FUSION_SEGMENTED_FIND_HPP_INCLUDED)
#define BOOST_FUSION_SEGMENTED_FIND_HPP_INCLUDED
#include <boost/type_traits/remove_const.hpp>
#include <boost/fusion/algorithm/query/find_fwd.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/support/segmented_fold_until.hpp>
namespace boost { namespace fusion { namespace detail
{
template <typename T>
struct segmented_find_fun
{
template <typename Sig>
struct result;
template <typename This, typename Sequence, typename State, typename Context>
struct result<This(Sequence&, State&, Context&)>
{
typedef
typename result_of::find<Sequence, T>::type
iterator_type;
typedef
typename result_of::make_segmented_iterator<
iterator_type
, typename remove_const<Context>::type
>::type
segmented_iterator_type;
typedef
typename mpl::if_<
result_of::equal_to<
iterator_type
, typename result_of::end<Sequence>::type
>
, fusion::result<typename remove_const<State>::type, continue_>, // NOT FOUND
fusion::result<segmented_iterator_type, break_> // FOUND
>::type
type;
};
template <typename Sequence, typename State, typename Context>
typename result<segmented_find_fun(Sequence&, State const&, Context const&)>::type
operator()(Sequence& seq, State const&state, Context const& context) const
{
typedef
typename result_of::equal_to<
typename result_of::find<Sequence, T>::type
, typename result_of::end<Sequence>::type
>::type
not_found;
return call(seq, state, context, not_found());
}
private:
template <typename Sequence, typename State, typename Context>
typename result<segmented_find_fun(Sequence&, State const&, Context const&)>::type
call(Sequence&, State const&state, Context const&, mpl::true_) const
{
return state;
}
template <typename Sequence, typename State, typename Context>
typename result<segmented_find_fun(Sequence&, State const&, Context const&)>::type
call(Sequence& seq, State const&, Context const& context, mpl::false_) const
{
return fusion::make_segmented_iterator(fusion::find<T>(seq), context);
}
};
template <typename Sequence, typename T>
struct result_of_segmented_find
{
struct filter
{
typedef
typename result_of::segmented_fold_until<
Sequence
, typename result_of::end<Sequence>::type
, segmented_find_fun<T>
>::type
type;
static type call(Sequence& seq)
{
return fusion::segmented_fold_until(
seq
, fusion::end(seq)
, detail::segmented_find_fun<T>());
}
};
typedef typename filter::type type;
};
}}}
#endif

View File

@ -0,0 +1,108 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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)
==============================================================================*/
#if !defined(BOOST_FUSION_SEGMENTED_FIND_IF_HPP_INCLUDED)
#define BOOST_FUSION_SEGMENTED_FIND_IF_HPP_INCLUDED
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/fusion/algorithm/query/find_if_fwd.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/support/segmented_fold_until.hpp>
namespace boost { namespace fusion { namespace detail
{
template <typename Pred>
struct segmented_find_if_fun
{
template <typename Sig>
struct result;
template <typename This, typename Sequence, typename State, typename Context>
struct result<This(Sequence&, State&, Context&)>
{
typedef
typename result_of::find_if<Sequence, Pred>::type
iterator_type;
typedef
typename result_of::make_segmented_iterator<
iterator_type
, typename remove_const<Context>::type
>::type
segmented_iterator_type;
typedef
typename mpl::if_<
result_of::equal_to<
iterator_type
, typename result_of::end<Sequence>::type
>
, fusion::result<typename remove_const<State>::type, continue_>, // NOT FOUND
fusion::result<segmented_iterator_type, break_> // FOUND
>::type
type;
};
template <typename Sequence, typename State, typename Context>
typename result<segmented_find_if_fun(Sequence&, State const&, Context const&)>::type
operator()(Sequence& seq, State const& state, Context const& context) const
{
typedef
typename result_of::equal_to<
typename result_of::find_if<Sequence, Pred>::type
, typename result_of::end<Sequence>::type
>::type
not_found;
return call(seq, state, context, not_found());
}
private:
template <typename Sequence, typename State, typename Context>
typename result<segmented_find_if_fun(Sequence&, State const&, Context const&)>::type
call(Sequence&, State const& state, Context const&, mpl::true_) const
{
return state;
}
template <typename Sequence, typename State, typename Context>
typename result<segmented_find_if_fun(Sequence&, State const&, Context const&)>::type
call(Sequence& seq, State const&, Context const& context, mpl::false_) const
{
return fusion::make_segmented_iterator(fusion::find_if<Pred>(seq), context);
}
};
template <typename Sequence, typename Pred>
struct result_of_segmented_find_if
{
struct filter
{
typedef
typename result_of::segmented_fold_until<
Sequence
, typename result_of::end<Sequence>::type
, segmented_find_if_fun<Pred>
>::type
type;
static type call(Sequence& seq)
{
return fusion::segmented_fold_until(
seq
, fusion::end(seq)
, segmented_find_if_fun<Pred>());
}
};
typedef typename filter::type type;
};
}}}
#endif

View File

@ -1,114 +0,0 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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)
==============================================================================*/
#if !defined(BOOST_FUSION_FIND_IF_S_HPP_INCLUDED)
#define BOOST_FUSION_FIND_IF_S_HPP_INCLUDED
#include <boost/type_traits/remove_const.hpp>
#include <boost/fusion/algorithm/query/find_if.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/support/segmented_fold_until.hpp>
namespace boost { namespace fusion { namespace detail
{
template<typename Pred>
struct segmented_find_if_fun
{
template<typename Sig>
struct result;
template<typename This, typename Range, typename State, typename Context>
struct result<This(Range&, State&, Context&)>
{
typedef
typename result_of::find_if<Range, Pred>::type
iterator_type;
typedef
typename result_of::make_segmented_iterator<
iterator_type,
typename remove_const<Context>::type
>::type
segmented_iterator_type;
typedef
typename mpl::if_<
result_of::equal_to<
iterator_type,
typename result_of::end<Range>::type
>,
fusion::result<typename remove_const<State>::type, continue_>, // NOT FOUND
fusion::result<segmented_iterator_type, break_> // FOUND
>::type
type;
};
template<typename Range, typename State, typename Context>
typename result<segmented_find_if_fun(Range&, State const&, Context const&)>::type
operator()(Range& rng, State const& state, Context const& context) const
{
typedef
typename result_of::equal_to<
typename result_of::find_if<Range, Pred>::type,
typename result_of::end<Range>::type
>::type
not_found;
return call(rng, state, context, not_found());
}
private:
template<typename Range, typename State, typename Context>
typename result<segmented_find_if_fun(Range&, State const&, Context const&)>::type
call(Range&, State const& state, Context const&, mpl::true_) const
{
return state;
}
template<typename Range, typename State, typename Context>
typename result<segmented_find_if_fun(Range&, State const&, Context const&)>::type
call(Range& rng, State const&, Context const& context, mpl::false_) const
{
return fusion::make_segmented_iterator(fusion::find_if<Pred>(rng), context);
}
};
}}}
namespace boost { namespace fusion
{
namespace result_of
{
template <typename Sequence, typename Pred>
struct find_if_s
: result_of::segmented_fold_until<
Sequence,
typename result_of::end<Sequence>::type,
detail::segmented_find_if_fun<Pred> >
{};
}
template <typename Pred, typename Sequence>
typename result_of::find_if_s<Sequence, Pred>::type
find_if_s(Sequence& seq)
{
return fusion::segmented_fold_until(
seq,
fusion::end(seq),
detail::segmented_find_if_fun<Pred>());
}
template <typename Pred, typename Sequence>
typename result_of::find_if_s<Sequence const, Pred>::type
find_if_s(Sequence const& seq)
{
return fusion::segmented_fold_until(
seq, fusion::end(seq),
detail::segmented_find_if_fun<Pred>());
}
}}
#endif

View File

@ -1,115 +0,0 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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)
==============================================================================*/
#if !defined(BOOST_FUSION_FIND_S_HPP_INCLUDED)
#define BOOST_FUSION_FIND_S_HPP_INCLUDED
#include <boost/type_traits/remove_const.hpp>
#include <boost/fusion/algorithm/query/find.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/support/segmented_fold_until.hpp>
namespace boost { namespace fusion { namespace detail
{
template<typename T>
struct segmented_find_fun
{
template<typename Sig>
struct result;
template<typename This, typename Range, typename State, typename Context>
struct result<This(Range&, State&, Context&)>
{
typedef
typename result_of::find<Range, T>::type
iterator_type;
typedef
typename result_of::make_segmented_iterator<
iterator_type,
typename remove_const<Context>::type
>::type
segmented_iterator_type;
typedef
typename mpl::if_<
result_of::equal_to<
iterator_type,
typename result_of::end<Range>::type
>,
fusion::result<typename remove_const<State>::type, continue_>, // NOT FOUND
fusion::result<segmented_iterator_type, break_> // FOUND
>::type
type;
};
template<typename Range, typename State, typename Context>
typename result<segmented_find_fun(Range&, State const&, Context const&)>::type
operator()(Range& rng, State const&state, Context const& context) const
{
typedef
typename result_of::equal_to<
typename result_of::find<Range, T>::type,
typename result_of::end<Range>::type
>::type
not_found;
return call(rng, state, context, not_found());
}
private:
template<typename Range, typename State, typename Context>
typename result<segmented_find_fun(Range&, State const&, Context const&)>::type
call(Range&, State const&state, Context const&, mpl::true_) const
{
return state;
}
template<typename Range, typename State, typename Context>
typename result<segmented_find_fun(Range&, State const&, Context const&)>::type
call(Range& rng, State const&, Context const& context, mpl::false_) const
{
return fusion::make_segmented_iterator(fusion::find<T>(rng), context);
}
};
}}}
namespace boost { namespace fusion
{
namespace result_of
{
template <typename Sequence, typename T>
struct find_s
: result_of::segmented_fold_until<
Sequence,
typename result_of::end<Sequence>::type,
detail::segmented_find_fun<T> >
{};
}
template <typename T, typename Sequence>
typename result_of::find_s<Sequence, T>::type
find_s(Sequence& seq)
{
return fusion::segmented_fold_until(
seq,
fusion::end(seq),
detail::segmented_find_fun<T>());
}
template <typename T, typename Sequence>
typename result_of::find_s<Sequence const, T>::type
find_s(Sequence const& seq)
{
return fusion::segmented_fold_until(
seq,
fusion::end(seq),
detail::segmented_find_fun<T>());
}
}}
#endif

View File

@ -1,5 +1,6 @@
/*============================================================================= /*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2011 Eric Niebler
Distributed under the Boost Software License, Version 1.0. (See accompanying 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) file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -7,13 +8,15 @@
#if !defined(FUSION_FIND_05052005_1107) #if !defined(FUSION_FIND_05052005_1107)
#define FUSION_FIND_05052005_1107 #define FUSION_FIND_05052005_1107
#include <boost/fusion/algorithm/query/find_if_fwd.hpp>
#include <boost/fusion/algorithm/query/detail/find_if.hpp> #include <boost/fusion/algorithm/query/detail/find_if.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp> #include <boost/fusion/algorithm/query/detail/segmented_find.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/iterator/key_of.hpp> #include <boost/fusion/iterator/key_of.hpp>
#include <boost/fusion/iterator/value_of.hpp> #include <boost/fusion/iterator/value_of.hpp>
#include <boost/fusion/support/category_of.hpp> #include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/support/is_segmented.hpp>
#include <boost/mpl/if.hpp> #include <boost/mpl/if.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/type_traits/is_same.hpp> #include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_const.hpp> #include <boost/type_traits/is_const.hpp>
#include <boost/utility/enable_if.hpp> #include <boost/utility/enable_if.hpp>
@ -22,17 +25,14 @@ namespace boost { namespace fusion
{ {
namespace result_of namespace result_of
{ {
template < template <typename Sequence, typename T>
typename Sequence
, typename T
>
struct find struct find
{ : mpl::if_<
typedef traits::is_segmented<Sequence>
detail::static_find_if< , detail::result_of_segmented_find<Sequence, T>
typename result_of::begin<Sequence>::type , detail::result_of_find_if<
, typename result_of::end<Sequence>::type Sequence,
, is_same< is_same<
typename mpl::if_< typename mpl::if_<
traits::is_associative<Sequence> traits::is_associative<Sequence>
, key_of<mpl::_1> , key_of<mpl::_1>
@ -41,10 +41,8 @@ namespace boost { namespace fusion
, T , T
> >
> >
filter; >::type
{};
typedef typename filter::type type;
};
} }
template <typename T, typename Sequence> template <typename T, typename Sequence>
@ -56,7 +54,7 @@ namespace boost { namespace fusion
find(Sequence& seq) find(Sequence& seq)
{ {
typedef typename result_of::find<Sequence, T>::filter filter; typedef typename result_of::find<Sequence, T>::filter filter;
return filter::call(fusion::begin(seq)); return filter::call(seq);
} }
template <typename T, typename Sequence> template <typename T, typename Sequence>
@ -64,9 +62,8 @@ namespace boost { namespace fusion
find(Sequence const& seq) find(Sequence const& seq)
{ {
typedef typename result_of::find<Sequence const, T>::filter filter; typedef typename result_of::find<Sequence const, T>::filter filter;
return filter::call(fusion::begin(seq)); return filter::call(seq);
} }
}} }}
#endif #endif

View File

@ -0,0 +1,34 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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)
==============================================================================*/
#if !defined(BOOST_FUSION_FIND_FWD_HPP_INCLUDED)
#define BOOST_FUSION_FIND_FWD_HPP_INCLUDED
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_const.hpp>
namespace boost { namespace fusion
{
namespace result_of
{
template <typename Sequence, typename T>
struct find;
}
template <typename T, typename Sequence>
inline typename
lazy_disable_if<
is_const<Sequence>
, result_of::find<Sequence, T>
>::type const
find(Sequence& seq);
template <typename T, typename Sequence>
inline typename result_of::find<Sequence const, T>::type const
find(Sequence const& seq);
}}
#endif

View File

@ -1,5 +1,6 @@
/*============================================================================= /*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2011 Eric Niebler
Distributed under the Boost Software License, Version 1.0. (See accompanying 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) file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -7,15 +8,17 @@
#if !defined(FUSION_FIND_IF_05052005_1108) #if !defined(FUSION_FIND_IF_05052005_1108)
#define FUSION_FIND_IF_05052005_1108 #define FUSION_FIND_IF_05052005_1108
#include <boost/fusion/algorithm/query/find_if_fwd.hpp>
#include <boost/fusion/algorithm/query/detail/find_if.hpp> #include <boost/fusion/algorithm/query/detail/find_if.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp> #include <boost/fusion/algorithm/query/detail/segmented_find_if.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/iterator/value_of.hpp> #include <boost/fusion/iterator/value_of.hpp>
#include <boost/mpl/bind.hpp> #include <boost/fusion/support/is_segmented.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/quote.hpp>
#include <boost/utility/enable_if.hpp> #include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_const.hpp> #include <boost/type_traits/is_const.hpp>
#include <boost/mpl/bind.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/quote.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
@ -23,20 +26,18 @@ namespace boost { namespace fusion
{ {
template <typename Sequence, typename Pred> template <typename Sequence, typename Pred>
struct find_if struct find_if
{ : mpl::if_<
typedef traits::is_segmented<Sequence>
detail::static_find_if< , detail::result_of_segmented_find_if<Sequence, Pred>
typename result_of::begin<Sequence>::type , detail::result_of_find_if<
, typename result_of::end<Sequence>::type Sequence,
, mpl::bind1< mpl::bind1<
typename mpl::lambda<Pred>::type typename mpl::lambda<Pred>::type
, mpl::bind1<mpl::quote1<value_of>,mpl::_1> , mpl::bind1<mpl::quote1<value_of>, mpl::_1>
> >
> >
filter; >::type
{};
typedef typename filter::type type;
};
} }
template <typename Pred, typename Sequence> template <typename Pred, typename Sequence>
@ -48,7 +49,7 @@ namespace boost { namespace fusion
find_if(Sequence& seq) find_if(Sequence& seq)
{ {
typedef typename result_of::find_if<Sequence, Pred>::filter filter; typedef typename result_of::find_if<Sequence, Pred>::filter filter;
return filter::call(fusion::begin(seq)); return filter::call(seq);
} }
template <typename Pred, typename Sequence> template <typename Pred, typename Sequence>
@ -56,9 +57,8 @@ namespace boost { namespace fusion
find_if(Sequence const& seq) find_if(Sequence const& seq)
{ {
typedef typename result_of::find_if<Sequence const, Pred>::filter filter; typedef typename result_of::find_if<Sequence const, Pred>::filter filter;
return filter::call(fusion::begin(seq)); return filter::call(seq);
} }
}} }}
#endif #endif

View File

@ -0,0 +1,35 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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)
==============================================================================*/
#if !defined(BOOST_FUSION_FIND_IF_FWD_HPP_INCLUDED)
#define BOOST_FUSION_FIND_IF_FWD_HPP_INCLUDED
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_const.hpp>
// Forward declaration of find_if algorithm
namespace boost { namespace fusion
{
namespace result_of
{
template <typename Sequence, typename Pred>
struct find_if;
}
template <typename Pred, typename Sequence>
typename
lazy_disable_if<
is_const<Sequence>
, result_of::find_if<Sequence, Pred>
>::type
find_if(Sequence& seq);
template <typename Pred, typename Sequence>
typename result_of::find_if<Sequence const, Pred>::type const
find_if(Sequence const& seq);
}}
#endif

View File

@ -24,7 +24,7 @@ namespace boost { namespace fusion
namespace detail namespace detail
{ {
template <typename Range, typename Stack> template <typename Sequence, typename Stack>
struct segmented_begin_impl; struct segmented_begin_impl;
//bool is_invalid(stack) //bool is_invalid(stack)
@ -40,7 +40,7 @@ namespace boost { namespace fusion
> >
{}; {};
////Advance the first iterator in the range at the ////Advance the first iterator in the seq at the
////top of a stack of iterator ranges. Return the ////top of a stack of iterator ranges. Return the
////new stack. ////new stack.
//auto pop_front_car(stack) //auto pop_front_car(stack)
@ -126,7 +126,7 @@ namespace boost { namespace fusion
template < template <
typename Stack, typename Stack,
typename Range = typename Sequence =
typename remove_reference< typename remove_reference<
typename add_const< typename add_const<
typename result_of::deref< typename result_of::deref<
@ -135,7 +135,7 @@ namespace boost { namespace fusion
>::type >::type
>::type, >::type,
typename Result = typename Result =
typename segmented_begin_impl<Range, Stack>::type, typename segmented_begin_impl<Sequence, Stack>::type,
bool IsInvalid = bool IsInvalid =
is_invalid<Result>::value> is_invalid<Result>::value>
struct segmented_next_impl_recurse2 struct segmented_next_impl_recurse2
@ -149,14 +149,14 @@ namespace boost { namespace fusion
} }
}; };
template <typename Stack, typename Range, typename Result> template <typename Stack, typename Sequence, typename Result>
struct segmented_next_impl_recurse2<Stack, Range, Result, false> struct segmented_next_impl_recurse2<Stack, Sequence, Result, false>
{ {
typedef Result type; typedef Result type;
static type call(Stack const & stack) static type call(Stack const & stack)
{ {
return segmented_begin_impl<Range, Stack>::call(*stack.car.first, stack); return segmented_begin_impl<Sequence, Stack>::call(*stack.car.first, stack);
} }
}; };
@ -210,7 +210,7 @@ namespace boost { namespace fusion
//auto segmented_next_impl(stack) //auto segmented_next_impl(stack)
//{ //{
// // car(stack) is a range of values, not a range of segments // // car(stack) is a seq of values, not a seq of segments
// auto next = pop_front_car(stack); // auto next = pop_front_car(stack);
// if (is_invalid(next)) // if (is_invalid(next))
// return segmented_next_impl_recurse(cdr(next)); // return segmented_next_impl_recurse(cdr(next));

View File

@ -12,24 +12,24 @@
namespace boost { namespace fusion { namespace detail namespace boost { namespace fusion { namespace detail
{ {
//auto segmented_begin( rng ) //auto segmented_begin( seq )
//{ //{
// return make_segmented_iterator( segmented_begin_impl( rng, nil ) ); // return make_segmented_iterator( segmented_begin_impl( seq, nil ) );
//} //}
template<typename Range> template <typename Sequence>
struct segmented_begin struct segmented_begin
{ {
typedef typedef
segmented_iterator< segmented_iterator<
typename segmented_begin_impl<Range, fusion::nil>::type typename segmented_begin_impl<Sequence, fusion::nil>::type
> >
type; type;
static type call(Range & rng) static type call(Sequence& seq)
{ {
return type( return type(
segmented_begin_impl<Range, fusion::nil>::call(rng, fusion::nil())); segmented_begin_impl<Sequence, fusion::nil>::call(seq, fusion::nil()));
} }
}; };

View File

@ -27,80 +27,80 @@ namespace boost { namespace fusion { namespace detail
template <typename Sig> template <typename Sig>
struct result; struct result;
template <typename This, typename Range, typename State, typename Context> template <typename This, typename Sequence, typename State, typename Context>
struct result<This(Range&, State&, Context&)> struct result<This(Sequence&, State&, Context&)>
{ {
typedef typedef
iterator_range< iterator_range<
typename fusion::result_of::begin<Range>::type, typename fusion::result_of::begin<Sequence>::type
typename fusion::result_of::end<Range>::type , typename fusion::result_of::end<Sequence>::type
> >
range_type; range_type;
typedef typedef
fusion::result< fusion::result<
cons<range_type, typename remove_const<Context>::type>, cons<range_type, typename remove_const<Context>::type>
fusion::break_ , fusion::break_
> >
type; type;
}; };
template <typename Range, typename State, typename Context> template <typename Sequence, typename State, typename Context>
typename result<segmented_begin_fun(Range&, State const&, Context const&)>::type typename result<segmented_begin_fun(Sequence&, State const&, Context const&)>::type
operator()(Range& rng, State const&, Context const& context) const operator()(Sequence& seq, State const&, Context const& context) const
{ {
typedef typedef
iterator_range< iterator_range<
typename fusion::result_of::begin<Range>::type, typename fusion::result_of::begin<Sequence>::type
typename fusion::result_of::end<Range>::type , typename fusion::result_of::end<Sequence>::type
> >
range_type; range_type;
return cons<range_type, Context>(range_type(fusion::begin(rng), fusion::end(rng)), context); return cons<range_type, Context>(range_type(fusion::begin(seq), fusion::end(seq)), context);
} }
}; };
template <typename Range, typename Stack, bool IsSegmented = traits::is_segmented<Range>::type::value> template <typename Sequence, typename Stack, bool IsSegmented = traits::is_segmented<Sequence>::type::value>
struct segmented_begin_impl_aux struct segmented_begin_impl_aux
{ {
typedef typedef
segmented_end_impl<Range, Stack> segmented_end_impl<Sequence, Stack>
end_impl; end_impl;
typedef typedef
segmented_fold_until_impl< segmented_fold_until_impl<
Range, Sequence
result<typename end_impl::type, continue_>, , result<typename end_impl::type, continue_>
Stack, , Stack
segmented_begin_fun , segmented_begin_fun
> >
fold_impl; fold_impl;
typedef typename fold_impl::type::value_type type; typedef typename fold_impl::type::value_type type;
static type call(Range& rng, Stack const& stack) static type call(Sequence& seq, Stack const& stack)
{ {
return fold_impl::call(rng, end_impl::call(rng, stack), stack, segmented_begin_fun()).value; return fold_impl::call(seq, end_impl::call(seq, stack), stack, segmented_begin_fun()).value;
} }
}; };
template <typename Range, typename Stack> template <typename Sequence, typename Stack>
struct segmented_begin_impl_aux<Range, Stack, false> struct segmented_begin_impl_aux<Sequence, Stack, false>
{ {
typedef typename result_of::begin<Range>::type begin_type; typedef typename result_of::begin<Sequence>::type begin_type;
typedef typename result_of::end<Range>::type end_type; typedef typename result_of::end<Sequence>::type end_type;
typedef iterator_range<begin_type, end_type> pair_type; typedef iterator_range<begin_type, end_type> pair_type;
typedef cons<pair_type, Stack> type; typedef cons<pair_type, Stack> type;
static type call(Range& rng, Stack stack) static type call(Sequence& seq, Stack stack)
{ {
return type(pair_type(fusion::begin(rng), fusion::end(rng)), stack); return type(pair_type(fusion::begin(seq), fusion::end(seq)), stack);
} }
}; };
template <typename Range, typename Stack> template <typename Sequence, typename Stack>
struct segmented_begin_impl struct segmented_begin_impl
: segmented_begin_impl_aux<Range, Stack> : segmented_begin_impl_aux<Sequence, Stack>
{}; {};
}}} }}}

View File

@ -13,24 +13,24 @@
namespace boost { namespace fusion { namespace detail namespace boost { namespace fusion { namespace detail
{ {
//auto segmented_end( rng ) //auto segmented_end( seq )
//{ //{
// return make_segmented_iterator( segmented_end_impl( rng ) ); // return make_segmented_iterator( segmented_end_impl( seq ) );
//} //}
template<typename Range> template <typename Sequence>
struct segmented_end struct segmented_end
{ {
typedef typedef
segmented_iterator< segmented_iterator<
typename segmented_end_impl<Range, fusion::nil>::type typename segmented_end_impl<Sequence, fusion::nil>::type
> >
type; type;
static type call(Range & rng) static type call(Sequence & seq)
{ {
return type( return type(
segmented_end_impl<Range, fusion::nil>::call(rng, fusion::nil())); segmented_end_impl<Sequence, fusion::nil>::call(seq, fusion::nil()));
} }
}; };

View File

@ -22,23 +22,23 @@ namespace boost { namespace fusion
namespace boost { namespace fusion { namespace detail namespace boost { namespace fusion { namespace detail
{ {
//auto segmented_end_impl( rng, stack ) //auto segmented_end_impl( seq, stack )
//{ //{
// assert(is_segmented(rng)); // assert(is_segmented(seq));
// auto it = end(segments(rng)); // auto it = end(segments(seq));
// return cons(iterator_range(it, it), stack); // return cons(iterator_range(it, it), stack);
//} //}
template<typename Range, typename Stack> template <typename Sequence, typename Stack>
struct segmented_end_impl struct segmented_end_impl
{ {
BOOST_MPL_ASSERT((traits::is_segmented<Range>)); BOOST_MPL_ASSERT((traits::is_segmented<Sequence>));
typedef typedef
typename result_of::end< typename result_of::end<
typename remove_reference< typename remove_reference<
typename add_const< typename add_const<
typename result_of::segments<Range>::type typename result_of::segments<Sequence>::type
>::type >::type
>::type >::type
>::type >::type
@ -47,9 +47,9 @@ namespace boost { namespace fusion { namespace detail
typedef iterator_range<end_type, end_type> pair_type; typedef iterator_range<end_type, end_type> pair_type;
typedef cons<pair_type, Stack> type; typedef cons<pair_type, Stack> type;
static type call(Range & rng, Stack stack) static type call(Sequence & seq, Stack stack)
{ {
end_type end = fusion::end(fusion::segments(rng)); end_type end = fusion::end(fusion::segments(seq));
return type(pair_type(end, end), stack); return type(pair_type(end, end), stack);
} }
}; };

View File

@ -28,14 +28,14 @@ namespace boost { namespace fusion { namespace detail
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
template<typename Sequence, bool IsSegmented = traits::is_segmented<Sequence>::value> template<typename Sequence, bool IsSegmented = traits::is_segmented<Sequence>::value>
struct segmented_size_impl struct segmented_size_impl
: mpl::fold< : mpl::fold<
typename remove_reference< typename remove_reference<
typename add_const< typename add_const<
typename result_of::segments<Sequence>::type typename result_of::segments<Sequence>::type
>::type >::type
>::type, >::type
mpl::size_t<0>, , mpl::size_t<0>
mpl::plus<mpl::_1, segmented_size<mpl::_2> > , mpl::plus<mpl::_1, segmented_size<mpl::_2> >
>::type >::type
{}; {};

View File

@ -24,8 +24,8 @@
#include <boost/fusion/support/is_segmented.hpp> #include <boost/fusion/support/is_segmented.hpp>
#include <boost/fusion/sequence/intrinsic/segments.hpp> #include <boost/fusion/sequence/intrinsic/segments.hpp>
// fun(rng, state, context) // fun(seq, state, context)
// rng: a non-segmented range // seq: a non-segmented range
// state: the state of the fold so far // state: the state of the fold so far
// context: the path to the current range // context: the path to the current range
// //
@ -46,8 +46,8 @@ namespace boost { namespace fusion
{ {
typedef typedef
iterator_range< iterator_range<
Cur, Cur
typename result_of::end< , typename result_of::end<
typename remove_reference< typename remove_reference<
typename add_const< typename add_const<
typename result_of::deref< typename result_of::deref<
@ -118,31 +118,31 @@ namespace boost { namespace fusion
namespace detail namespace detail
{ {
template < template <
typename Begin, typename Begin
typename End, , typename End
typename State, , typename State
typename Context, , typename Context
typename Fun, , typename Fun
bool IsEmpty = result_of::empty< , bool IsEmpty = result_of::empty<
typename result_of::value_of<Begin>::type typename result_of::value_of<Begin>::type
>::type::value> >::type::value>
struct segmented_fold_until_iterate_skip_empty; struct segmented_fold_until_iterate_skip_empty;
template < template <
typename Begin, typename Begin
typename End, , typename End
typename State, , typename State
typename Context, , typename Context
typename Fun, , typename Fun
bool IsDone = result_of::equal_to<Begin, End>::type::value> , bool IsDone = result_of::equal_to<Begin, End>::type::value>
struct segmented_fold_until_iterate; struct segmented_fold_until_iterate;
template < template <
typename Range, typename Sequence
typename State, , typename State
typename Context, , typename Context
typename Fun, , typename Fun
bool IsSegmented = traits::is_segmented<Range>::type::value> , bool IsSegmented = traits::is_segmented<Sequence>::type::value>
struct segmented_fold_until_impl; struct segmented_fold_until_impl;
template <typename Segments, typename State, typename Context, typename Fun> template <typename Segments, typename State, typename Context, typename Fun>
@ -170,65 +170,65 @@ namespace boost { namespace fusion
// return segmented_iterator(push_context(cur, end, context)); // return segmented_iterator(push_context(cur, end, context));
//} //}
// //
//auto segmented_fold_until_impl(rng, state, context, fun) //auto segmented_fold_until_impl(seq, state, context, fun)
//{ //{
// if (is_segmented(rng)) // if (is_segmented(seq))
// { // {
// segmented_fold_until_on_segments(segments(rng), state, context, fun); // segmented_fold_until_on_segments(segments(seq), state, context, fun);
// } // }
// else // else
// { // {
// return fun(rng, state, context); // return fun(seq, state, context);
// } // }
//} //}
template < template <
typename Range, typename Sequence
typename State, , typename State
typename Context, , typename Context
typename Fun, , typename Fun
bool IsSegmented> , bool IsSegmented>
struct segmented_fold_until_impl struct segmented_fold_until_impl
{ {
typedef typedef
segmented_fold_until_on_segments< segmented_fold_until_on_segments<
typename remove_reference< typename remove_reference<
typename add_const< typename add_const<
typename result_of::segments<Range>::type typename result_of::segments<Sequence>::type
>::type >::type
>::type, >::type
State, , State
Context, , Context
Fun , Fun
> >
impl; impl;
typedef typename impl::type type; typedef typename impl::type type;
static type call(Range& rng, State const& state, Context const& context, Fun const& fun) static type call(Sequence& seq, State const& state, Context const& context, Fun const& fun)
{ {
return impl::call(fusion::segments(rng), state, context, fun); return impl::call(fusion::segments(seq), state, context, fun);
} }
}; };
template < template <
typename Range, typename Sequence
typename State, , typename State
typename Context, , typename Context
typename Fun> , typename Fun>
struct segmented_fold_until_impl<Range, State, Context, Fun, false> struct segmented_fold_until_impl<Sequence, State, Context, Fun, false>
{ {
typedef typedef
typename boost::result_of<Fun( typename boost::result_of<Fun(
Range&, Sequence&
typename add_reference<typename add_const<typename State::value_type>::type>::type, , typename add_reference<typename add_const<typename State::value_type>::type>::type
Context const& , Context const&
)>::type )>::type
type; type;
static type call(Range& rng, State const& state, Context const& context, Fun const& fun) static type call(Sequence& seq, State const& state, Context const& context, Fun const& fun)
{ {
return fun(rng, state.value, context); return fun(seq, state.value, context);
} }
}; };
@ -264,10 +264,10 @@ namespace boost { namespace fusion
typename add_const< typename add_const<
typename result_of::deref<Begin>::type typename result_of::deref<Begin>::type
>::type >::type
>::type, >::type
State, , State
next_context_type, , next_context_type
Fun , Fun
> >
fold_recurse_impl; fold_recurse_impl;
@ -277,51 +277,51 @@ namespace boost { namespace fusion
typedef typedef
segmented_fold_until_iterate< segmented_fold_until_iterate<
typename result_of::next<Begin>::type, typename result_of::next<Begin>::type
End, , End
next_state_type, , next_state_type
Context, , Context
Fun , Fun
> >
next_iteration_impl; next_iteration_impl;
typedef typedef
typename mpl::eval_if< typename mpl::eval_if<
typename next_state_type::continue_type, typename next_state_type::continue_type
next_iteration_impl, , next_iteration_impl
mpl::identity<next_state_type> , mpl::identity<next_state_type>
>::type >::type
type; type;
static type call(Begin const& beg, End const& end, State const& state, static type call(Begin const& beg, End const& end, State const& state
Context const& context, Fun const& fun) , Context const& context, Fun const& fun)
{ {
return call(beg, end, state, context, fun, typename next_state_type::continue_type()); return call(beg, end, state, context, fun, typename next_state_type::continue_type());
} }
static type call(Begin const& beg, End const& end, State const& state, static type call(Begin const& beg, End const& end, State const& state
Context const& context, Fun const& fun, mpl::true_) // continue , Context const& context, Fun const& fun, mpl::true_) // continue
{ {
return next_iteration_impl::call( return next_iteration_impl::call(
fusion::next(beg), fusion::next(beg)
end, , end
fold_recurse_impl::call( , fold_recurse_impl::call(
*beg, *beg
state, , state
push_context_impl::call(beg, end, context), , push_context_impl::call(beg, end, context)
fun), , fun)
context, , context
fun); , fun);
} }
static type call(Begin const& beg, End const& end, State const& state, static type call(Begin const& beg, End const& end, State const& state
Context const& context, Fun const& fun, mpl::false_) // break , Context const& context, Fun const& fun, mpl::false_) // break
{ {
return fold_recurse_impl::call( return fold_recurse_impl::call(
*beg, *beg
state, , state
push_context_impl::call(beg, end, context), , push_context_impl::call(beg, end, context)
fun); , fun);
} }
}; };
@ -330,18 +330,18 @@ namespace boost { namespace fusion
{ {
typedef typedef
segmented_fold_until_iterate< segmented_fold_until_iterate<
typename result_of::next<Begin>::type, typename result_of::next<Begin>::type
End, , End
State, , State
Context, , Context
Fun , Fun
> >
impl; impl;
typedef typename impl::type type; typedef typename impl::type type;
static type call(Begin const& beg, End const& end, State const& state, static type call(Begin const& beg, End const& end, State const& state
Context const& context, Fun const& fun) , Context const& context, Fun const& fun)
{ {
return impl::call(fusion::next(beg), end, state, context, fun); return impl::call(fusion::next(beg), end, state, context, fun);
} }
@ -356,8 +356,8 @@ namespace boost { namespace fusion
typedef typename impl::type type; typedef typename impl::type type;
static type call(Begin const& beg, End const& end, State const& state, static type call(Begin const& beg, End const& end, State const& state
Context const& context, Fun const& fun) , Context const& context, Fun const& fun)
{ {
return impl::call(beg, end, state, context, fun); return impl::call(beg, end, state, context, fun);
} }
@ -368,8 +368,8 @@ namespace boost { namespace fusion
{ {
typedef State type; typedef State type;
static type call(Begin const&, End const&, State const& state, static type call(Begin const&, End const&, State const& state
Context const&, Fun const&) , Context const&, Fun const&)
{ {
return state; return state;
} }
@ -380,11 +380,11 @@ namespace boost { namespace fusion
{ {
typedef typedef
segmented_fold_until_iterate< segmented_fold_until_iterate<
typename result_of::begin<Segments>::type, typename result_of::begin<Segments>::type
typename result_of::end<Segments>::type, , typename result_of::end<Segments>::type
State, , State
Context, , Context
Fun , Fun
> >
impl; impl;

View File

@ -7,6 +7,8 @@
#if !defined(BOOST_FUSION_SEGMENTED_FOLD_UNTIL_HPP_INCLUDED) #if !defined(BOOST_FUSION_SEGMENTED_FOLD_UNTIL_HPP_INCLUDED)
#define BOOST_FUSION_SEGMENTED_FOLD_UNTIL_HPP_INCLUDED #define BOOST_FUSION_SEGMENTED_FOLD_UNTIL_HPP_INCLUDED
#include <boost/type_traits/is_const.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/fusion/support/detail/segmented_fold_until_impl.hpp> #include <boost/fusion/support/detail/segmented_fold_until_impl.hpp>
#include <boost/fusion/view/iterator_range.hpp> #include <boost/fusion/view/iterator_range.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp> #include <boost/fusion/sequence/intrinsic/begin.hpp>
@ -16,45 +18,56 @@
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
//auto segmented_fold_until(rng, state, fun) //auto segmented_fold_until(seq, state, fun)
//{ //{
// return first(segmented_fold_until_impl(rng, state, nil, fun)); // return first(segmented_fold_until_impl(seq, state, nil, fun));
//} //}
namespace result_of namespace result_of
{ {
template <typename Range, typename State, typename Fun> template <typename Sequence, typename State, typename Fun>
struct segmented_fold_until struct segmented_fold_until
{ {
typedef typedef
detail::segmented_fold_until_impl< detail::segmented_fold_until_impl<
Range, Sequence
result<State, continue_>, , result<State, continue_>
fusion::nil, , fusion::nil
Fun , Fun
> >
impl; filter;
typedef typedef
typename impl::type::value_type typename filter::type::value_type
type; type;
}; };
} }
template <typename Range, typename State, typename Fun> template <typename Sequence, typename State, typename Fun>
typename result_of::segmented_fold_until<Range, State, Fun>::type typename
segmented_fold_until(Range& rng, State const& state, Fun const& fun) lazy_disable_if<
is_const<Sequence>
, result_of::segmented_fold_until<Sequence, State, Fun>
>::type
segmented_fold_until(Sequence& seq, State const& state, Fun const& fun)
{ {
typedef typename result_of::segmented_fold_until<Range, State, Fun>::impl impl; typedef
return impl::call(rng, state, fusion::nil(), fun).value; typename result_of::segmented_fold_until<Sequence, State, Fun>::filter
filter;
return filter::call(seq, state, fusion::nil(), fun).value;
} }
template <typename Range, typename State, typename Fun> template <typename Sequence, typename State, typename Fun>
typename result_of::segmented_fold_until<Range const, State, Fun>::type typename result_of::segmented_fold_until<Sequence const, State, Fun>::type
segmented_fold_until(Range const& rng, State const& state, Fun const& fun) segmented_fold_until(Sequence const& seq, State const& state, Fun const& fun)
{ {
typedef typename result_of::segmented_fold_until<Range const, State, Fun>::impl impl; typedef
return impl::call(rng, state, fusion::nil(), fun).value; typename result_of::segmented_fold_until<Sequence const, State, Fun>::filter
filter;
return filter::call(seq, state, fusion::nil(), fun).value;
} }
}} }}
#endif #endif

View File

@ -65,7 +65,7 @@ namespace boost { namespace fusion
static type static type
call(Iterator const& i) call(Iterator const& i)
{ {
return type(filter::call(i.first)); return type(filter::iter_call(i.first));
} }
}; };
}; };

View File

@ -55,7 +55,7 @@ namespace boost { namespace fusion
typedef Pred pred_type; typedef Pred pred_type;
filter_iterator(First const& in_first) filter_iterator(First const& in_first)
: first(filter::call(first_converter::call(in_first))) {} : first(filter::iter_call(first_converter::call(in_first))) {}
first_type first; first_type first;

View File

@ -53,9 +53,9 @@ namespace boost { namespace fusion
: is_segmented_iterator<typename Sequence::begin_type> : is_segmented_iterator<typename Sequence::begin_type>
{ {
BOOST_MPL_ASSERT_RELATION( BOOST_MPL_ASSERT_RELATION(
is_segmented_iterator<typename Sequence::begin_type>::value, is_segmented_iterator<typename Sequence::begin_type>::value
==, , ==
is_segmented_iterator<typename Sequence::end_type>::value); , is_segmented_iterator<typename Sequence::end_type>::value);
}; };
}; };
} }

View File

@ -82,16 +82,16 @@ namespace boost { namespace fusion { namespace detail
>::type >::type
>::type >::type
>::type >::type
>::type, >::type
typename Stack::cdr_type::car_type::end_type , typename Stack::cdr_type::car_type::end_type
>)); >));
typedef typedef
iterator_range< iterator_range<
typename result_of::next< typename result_of::next<
typename Stack::cdr_type::car_type::begin_type typename Stack::cdr_type::car_type::begin_type
>::type, >::type
typename result_of::end< , typename result_of::end<
typename remove_reference< typename remove_reference<
typename add_const< typename add_const<
typename result_of::segments< typename result_of::segments<
@ -116,8 +116,8 @@ namespace boost { namespace fusion { namespace detail
typedef typedef
segment_sequence< segment_sequence<
typename result_of::push_front< typename result_of::push_front<
rest_type const, rest_type const
typename recurse::type , typename recurse::type
>::type >::type
> >
type; type;
@ -130,8 +130,8 @@ namespace boost { namespace fusion { namespace detail
// make_segment_sequence_front(cdr(stack_begin)))); // make_segment_sequence_front(cdr(stack_begin))));
return type( return type(
fusion::push_front( fusion::push_front(
rest_type(fusion::next(stack.cdr.car.first), fusion::end(fusion::segments(*stack.car.first))), rest_type(fusion::next(stack.cdr.car.first), fusion::end(fusion::segments(*stack.car.first)))
recurse::call(stack.cdr))); , recurse::call(stack.cdr)));
} }
}; };
@ -149,14 +149,14 @@ namespace boost { namespace fusion { namespace detail
>::type >::type
>::type >::type
>::type >::type
>::type, >::type
typename Stack::cdr_type::car_type::end_type , typename Stack::cdr_type::car_type::end_type
>)); >));
typedef typedef
iterator_range< iterator_range<
typename Stack::cdr_type::car_type::begin_type, typename Stack::cdr_type::car_type::begin_type
typename result_of::end< , typename result_of::end<
typename remove_reference< typename remove_reference<
typename add_const< typename add_const<
typename result_of::deref< typename result_of::deref<
@ -226,8 +226,8 @@ namespace boost { namespace fusion { namespace detail
>::type >::type
>::type >::type
>::type >::type
>::type, >::type
typename Stack::cdr_type::car_type::end_type , typename Stack::cdr_type::car_type::end_type
>)); >));
typedef typedef
@ -246,8 +246,8 @@ namespace boost { namespace fusion { namespace detail
>::type >::type
>::type >::type
>::type >::type
>::type, >::type
typename Stack::cdr_type::car_type::begin_type , typename Stack::cdr_type::car_type::begin_type
> >
rest_type; rest_type;
@ -258,8 +258,8 @@ namespace boost { namespace fusion { namespace detail
typedef typedef
segment_sequence< segment_sequence<
typename result_of::push_back< typename result_of::push_back<
rest_type const, rest_type const
typename recurse::type , typename recurse::type
>::type >::type
> >
type; type;
@ -272,8 +272,8 @@ namespace boost { namespace fusion { namespace detail
// make_segment_sequence_back(cdr(stack_end)))); // make_segment_sequence_back(cdr(stack_end))));
return type( return type(
fusion::push_back( fusion::push_back(
rest_type(fusion::begin(fusion::segments(*stack.car.first)), stack.cdr.car.first), rest_type(fusion::begin(fusion::segments(*stack.car.first)), stack.cdr.car.first)
recurse::call(stack.cdr))); , recurse::call(stack.cdr)));
} }
}; };
@ -291,8 +291,8 @@ namespace boost { namespace fusion { namespace detail
>::type >::type
>::type >::type
>::type >::type
>::type, >::type
typename Stack::cdr_type::car_type::end_type , typename Stack::cdr_type::car_type::end_type
>)); >));
typedef typedef
@ -305,8 +305,8 @@ namespace boost { namespace fusion { namespace detail
>::type >::type
>::type >::type
>::type >::type
>::type, >::type
typename Stack::cdr_type::car_type::begin_type , typename Stack::cdr_type::car_type::begin_type
> >
type; type;
@ -362,19 +362,19 @@ namespace boost { namespace fusion { namespace detail
//} //}
template < template <
typename StackBegin, typename StackBegin
typename StackEnd, , typename StackEnd
int StackBeginSize = StackBegin::size::value, , int StackBeginSize = StackBegin::size::value
int StackEndSize = StackEnd::size::value> , int StackEndSize = StackEnd::size::value>
struct make_segmented_range_reduce; struct make_segmented_range_reduce;
template < template <
typename StackBegin, typename StackBegin
typename StackEnd, , typename StackEnd
bool SameSegment = , bool SameSegment =
result_of::equal_to< result_of::equal_to<
typename StackBegin::car_type::begin_type, typename StackBegin::car_type::begin_type
typename StackEnd::car_type::begin_type , typename StackEnd::car_type::begin_type
>::type::value> >::type::value>
struct make_segmented_range_reduce2 struct make_segmented_range_reduce2
{ {
@ -382,8 +382,8 @@ namespace boost { namespace fusion { namespace detail
iterator_range< iterator_range<
typename result_of::next< typename result_of::next<
typename StackBegin::car_type::begin_type typename StackBegin::car_type::begin_type
>::type, >::type
typename StackEnd::car_type::begin_type , typename StackEnd::car_type::begin_type
> >
rest_type; rest_type;
@ -391,10 +391,10 @@ namespace boost { namespace fusion { namespace detail
segment_sequence< segment_sequence<
typename result_of::push_back< typename result_of::push_back<
typename result_of::push_front< typename result_of::push_front<
rest_type const, rest_type const
typename make_segment_sequence_front<StackBegin>::type , typename make_segment_sequence_front<StackBegin>::type
>::type const, >::type const
typename make_segment_sequence_back<StackEnd>::type , typename make_segment_sequence_back<StackEnd>::type
>::type >::type
> >
type; type;
@ -412,9 +412,9 @@ namespace boost { namespace fusion { namespace detail
return type( return type(
fusion::push_back( fusion::push_back(
fusion::push_front( fusion::push_front(
rest_type(fusion::next(stack_begin.car.first), stack_end.car.first), rest_type(fusion::next(stack_begin.car.first), stack_end.car.first)
make_segment_sequence_front<StackBegin>::call(stack_begin)), , make_segment_sequence_front<StackBegin>::call(stack_begin))
make_segment_sequence_back<StackEnd>::call(stack_end))); , make_segment_sequence_back<StackEnd>::call(stack_end)));
} }
}; };
@ -423,8 +423,8 @@ namespace boost { namespace fusion { namespace detail
{ {
typedef typedef
make_segmented_range_reduce< make_segmented_range_reduce<
typename StackBegin::cdr_type, typename StackBegin::cdr_type
typename StackEnd::cdr_type , typename StackEnd::cdr_type
> >
impl; impl;
@ -448,8 +448,8 @@ namespace boost { namespace fusion { namespace detail
{ {
typedef typedef
iterator_range< iterator_range<
typename StackBegin::car_type::begin_type, typename StackBegin::car_type::begin_type
typename StackEnd::car_type::begin_type , typename StackEnd::car_type::begin_type
> >
range_type; range_type;
@ -483,8 +483,8 @@ namespace boost { namespace fusion { namespace detail
typedef typedef
make_segmented_range_reduce< make_segmented_range_reduce<
typename reverse_begin_cons::type, typename reverse_begin_cons::type
typename reverse_end_cons::type , typename reverse_end_cons::type
> >
impl; impl;
@ -493,8 +493,8 @@ namespace boost { namespace fusion { namespace detail
static type call(Begin const & begin, End const & end) static type call(Begin const & begin, End const & end)
{ {
return impl::call( return impl::call(
reverse_begin_cons::call(begin.context), reverse_begin_cons::call(begin.context)
reverse_end_cons::call(end.context)); , reverse_end_cons::call(end.context));
} }
}; };

View File

@ -29,8 +29,8 @@ namespace boost { namespace fusion
{ {
typedef typedef
detail::make_segmented_range< detail::make_segmented_range<
typename Sequence::begin_type, typename Sequence::begin_type
typename Sequence::end_type , typename Sequence::end_type
> >
impl; impl;

View File

@ -7,7 +7,7 @@
==============================================================================*/ ==============================================================================*/
#include <boost/detail/lightweight_test.hpp> #include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp> #include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/algorithm/query/ext_/find_s.hpp> #include <boost/fusion/algorithm/query/find.hpp>
#include <boost/fusion/container/generation/make_vector.hpp> #include <boost/fusion/container/generation/make_vector.hpp>
#include "../sequence/tree.hpp" #include "../sequence/tree.hpp"
@ -19,21 +19,21 @@ process_tree(Tree const &tree)
{ {
using namespace boost; using namespace boost;
typedef typename boost::fusion::result_of::find_s<Tree const, short>::type short_iter; typedef typename boost::fusion::result_of::find<Tree const, short>::type short_iter;
typedef typename boost::fusion::result_of::find_s<Tree const, float>::type float_iter; typedef typename boost::fusion::result_of::find<Tree const, float>::type float_iter;
typedef typename boost::fusion::result_of::find_s<Tree const, not_there>::type not_there_iter; typedef typename boost::fusion::result_of::find<Tree const, not_there>::type not_there_iter;
// find_if_s of a segmented data structure returns generic // find_if_s of a segmented data structure returns generic
// segmented iterators // segmented iterators
short_iter si = fusion::find_s<short>(tree); short_iter si = fusion::find<short>(tree);
float_iter fi = fusion::find_s<float>(tree); float_iter fi = fusion::find<float>(tree);
// they behave like ordinary Fusion iterators ... // they behave like ordinary Fusion iterators ...
BOOST_TEST((*si == short('d'))); BOOST_TEST((*si == short('d')));
BOOST_TEST((*fi == float(1))); BOOST_TEST((*fi == float(1)));
// Searching for something that's not there should return the end iterator. // Searching for something that's not there should return the end iterator.
not_there_iter nti = fusion::find_s<not_there>(tree); not_there_iter nti = fusion::find<not_there>(tree);
BOOST_TEST((nti == fusion::end(tree))); BOOST_TEST((nti == fusion::end(tree)));
} }

View File

@ -7,7 +7,7 @@
==============================================================================*/ ==============================================================================*/
#include <boost/detail/lightweight_test.hpp> #include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp> #include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/algorithm/query/ext_/find_if_s.hpp> #include <boost/fusion/algorithm/query/find_if.hpp>
#include <boost/fusion/container/generation/make_vector.hpp> #include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/mpl/placeholders.hpp> #include <boost/mpl/placeholders.hpp>
#include <boost/type_traits/is_same.hpp> #include <boost/type_traits/is_same.hpp>
@ -22,21 +22,21 @@ process_tree(Tree const &tree)
using namespace boost; using namespace boost;
using mpl::_; using mpl::_;
typedef typename boost::fusion::result_of::find_if_s<Tree const, is_same<_,short> >::type short_iter; typedef typename boost::fusion::result_of::find_if<Tree const, is_same<_,short> >::type short_iter;
typedef typename boost::fusion::result_of::find_if_s<Tree const, is_same<_,float> >::type float_iter; typedef typename boost::fusion::result_of::find_if<Tree const, is_same<_,float> >::type float_iter;
typedef typename boost::fusion::result_of::find_if_s<Tree const, is_same<_,not_there> >::type not_there_iter; typedef typename boost::fusion::result_of::find_if<Tree const, is_same<_,not_there> >::type not_there_iter;
// find_if_s of a segmented data structure returns generic // find_if of a segmented data structure returns generic
// segmented iterators // segmented iterators
short_iter si = fusion::find_if_s<is_same<_,short> >(tree); short_iter si = fusion::find_if<is_same<_,short> >(tree);
float_iter fi = fusion::find_if_s<is_same<_,float> >(tree); float_iter fi = fusion::find_if<is_same<_,float> >(tree);
// they behave like ordinary Fusion iterators ... // they behave like ordinary Fusion iterators ...
BOOST_TEST((*si == short('d'))); BOOST_TEST((*si == short('d')));
BOOST_TEST((*fi == float(1))); BOOST_TEST((*fi == float(1)));
// Searching for something that's not there should return the end iterator. // Searching for something that's not there should return the end iterator.
not_there_iter nti = fusion::find_if_s<is_same<_,not_there> >(tree); not_there_iter nti = fusion::find_if<is_same<_,not_there> >(tree);
BOOST_TEST((nti == fusion::end(tree))); BOOST_TEST((nti == fusion::end(tree)));
} }

View File

@ -8,7 +8,7 @@
#include <sstream> #include <sstream>
#include <boost/detail/lightweight_test.hpp> #include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/algorithm/iteration/ext_/for_each_s.hpp> #include <boost/fusion/algorithm/iteration/ext_/for_each_s.hpp>
#include <boost/fusion/algorithm/query/ext_/find_if_s.hpp> #include <boost/fusion/algorithm/query/find_if.hpp>
#include <boost/fusion/container/vector/vector.hpp> #include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/generation/make_vector.hpp> #include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/view/iterator_range/iterator_range.hpp> #include <boost/fusion/view/iterator_range/iterator_range.hpp>
@ -43,16 +43,16 @@ process_tree(Tree const &tree)
using namespace fusion; using namespace fusion;
using mpl::_; using mpl::_;
typedef typename boost::fusion::result_of::find_if_s<Tree const, is_same<_,short> >::type short_iter; typedef typename boost::fusion::result_of::find_if<Tree const, is_same<_,short> >::type short_iter;
typedef typename boost::fusion::result_of::find_if_s<Tree const, is_same<_,float> >::type float_iter; typedef typename boost::fusion::result_of::find_if<Tree const, is_same<_,float> >::type float_iter;
typedef iterator_range<short_iter, float_iter> slice_t; typedef iterator_range<short_iter, float_iter> slice_t;
BOOST_STATIC_ASSERT(traits::is_segmented<slice_t>::value); BOOST_STATIC_ASSERT(traits::is_segmented<slice_t>::value);
// find_if_s of a segmented data structure returns generic // find_if of a segmented data structure returns generic
// segmented iterators // segmented iterators
short_iter si = find_if_s<is_same<_,short> >(tree); short_iter si = find_if<is_same<_,short> >(tree);
float_iter fi = find_if_s<is_same<_,float> >(tree); float_iter fi = find_if<is_same<_,float> >(tree);
// If you put them in an iterator range, the range // If you put them in an iterator range, the range
// is automatically a segmented data structure. // is automatically a segmented data structure.